Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread TCombobox ItemIndex
Mon, Mar 4 2013 10:23 AMPermanent Link

Matthew Jones

First, I just took some simple Delphi code that fills a list with some template
stuff I want, and copied it into a new unit in EWB, and it compiled without change.
Sweet!

But then I put the items in a TComboBox, and it is not behaving as I expect.
Basically, MyCombo.ItemIndex := 1; does not change the value shown - it stays blank.
Have I missed something?

/Matthew Jones/
Mon, Mar 4 2013 11:08 AMPermanent Link

Raul

Team Elevate Team Elevate

On 3/4/2013 10:23 AM, (Matthew Jones) wrote:
>
> But then I put the items in a TComboBox, and it is not behaving as I expect.
> Basically, MyCombo.ItemIndex := 1; does not change the value shown - it stays blank.
> Have I missed something?

No - this looks like a bug. Seems to be UI update issue since the
ItemIndex is changed (if you query for it after changing it in code).

Raul
Tue, Mar 5 2013 8:58 AMPermanent Link

Markku Nevalainen

Raul wrote:
>
> No - this looks like a bug. Seems to be UI update issue since the
> ItemIndex is changed (if you query for it after changing it in code).

I already asked about this TCheckbox related question in other theread.
I'll re-send it, in hope someone knows some work around for it:

---
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if Label2.Font.Color= clRed
  then Label2.Font.Color := clBlack
  else Label2.Font.Color := clRed;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  CheckBox1.Checked := NOT CheckBox1.Checked;
end;

That works in Delphi, clicking Button1 the Checkbox.Checked state
changes and the font color in Label2 changes.
With EWB only the visible Checked state changes, but the Label2 color
does not change, the event seems not Fire right. Any ideas for this?
---

I wonder when would be the next EWB release be out, if there is no work
arounds available? Thanks.

Mats
Tue, Mar 5 2013 9:08 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mats

>That works in Delphi, clicking Button1 the Checkbox.Checked state
>changes and the font color in Label2 changes.
>With EWB only the visible Checked state changes, but the Label2 color
>does not change, the event seems not Fire right. Any ideas for this?

You're half right. The standard Delphi checkbox component works like that but third party ones may not. Personally I don't think the OnClick event should fire when the checked state changes.

Roy
Tue, Mar 5 2013 9:30 AMPermanent Link

Markku Nevalainen

Roy Lambert wrote:

> Personally I don't think the OnClick event should fire when the
> checked state changes.

All right. But then the works around how to programmatically *make it
fire* under EWB?

Mats
Tue, Mar 5 2013 9:44 AMPermanent Link

Matthew Jones

Just call CheckBox1Click(nil); in the Button1Click routine. While it is sort of
nice to have them fire automatically, I have a lot of code in my Delphi forms that
checks if it is "me" loading the form state to show the current situation, or if it
is really the user. Not auto-firing events clarifies that.

/Matthew Jones/
Tue, Mar 5 2013 10:34 AMPermanent Link

Markku Nevalainen

(Matthew Jones) wrote:

> Just call CheckBox1Click(nil);

I thought I tried that in several ways but EWB refused to compile. But
you are right it does compile and work.

Yet only Fires the event, but it does not alter the checked state. Doing
it his way in two phases, and in this order, both the Checked state and
the event will finally fire programatically.

CheckBox1.Checked := NOT CheckBox1.Checked;
CheckBox1Click(nil);

Mats
Tue, Mar 5 2013 12:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mats,

<< Yet only Fires the event, but it does not alter the checked state. >>

That is correct - an OnClick event does not change the state of any control.
It simply reflects that the user initiated the particular action.

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Mar 5 2013 12:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Just call CheckBox1Click(nil); in the Button1Click routine. While it is
sort of nice to have them fire automatically, I have a lot of code in my
Delphi forms that checks if it is "me" loading the form state to show the
current situation, or if it is really the user. Not auto-firing events
clarifies that. >>

Yep, this is why it behaves the way that it does in EWB.  The alternative is
to have a bunch of flags to know when/how to prevent hard loops, etc. in the
UI logic.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Mar 5 2013 12:55 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< But then I put the items in a TComboBox, and it is not behaving as I
expect. Basically, MyCombo.ItemIndex := 1; does not change the value shown -
it stays blank. Have I missed  something? >>

No, it's a bug.  The fix is this in the WebCtrls unit:

procedure TListControl.SetItemIndex(Value: Integer);
begin
  THTMLSelectElement(Input).selectedIndex:=Value;
  DoChange;  <<< Add this
end;

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com


Page 1 of 2Next Page »
Jump to Page:  1 2
Image