Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2009-12

ComboBox OnChange and OnSelect

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Hi,

I don't know which is the right behavior but GTK2 and QT bindings work differently.
With QT bindings, ComboBox OnChange and OnSelect events are called also when adding items in program like:

  ComboBox.Items.Add('text');

With GTK2 bindings they are not called.

I needed to react only when user selects an item in combobox. The GTK version worked straight away but I had to make an "UpdatingList" flag to make the QT version work.

Now, calling OnChange when items are added is actually logical (because the list is changing) but OnSelect should be called only on user's selection (IMO).

I don't know how Delphi does it.

Regards,
Juha Manninen

zeljko
to Juha Manninen
Juha Manninen wrote 18 lines
Hi, I don't know which is the right behavior but GTK2 and QT bindings work differently. With QT bindings, ComboBox OnChange and OnSelect events are called also when adding items in program like: ComboBox.Items.Add('text'); With GTK2 bindings they are not called. I needed to react only when user selects an item in combobox. The GTK version worked straight away but I had to make an "UpdatingList" flag to make the QT version work. Now, calling OnChange when items are added is actually logical (because the list is changing) but OnSelect should be called only on user's selection (IMO). I don't know how Delphi does it.

It's easy to get delphi behaviour with qt, just write here what is the right behaviour.

zeljko

Juha Manninen
to zeljko
zeljko wrote
It's easy to get delphi behaviour with qt, just write here what is the right behaviour.

Well, I don't remember it and I can't test it now because I don't have Delphi or even Windows in my machine currently.

I was working with Delphi for many years. This autumn things changed as I started studying again (as a middle aged man).

Anyway, I think OnChange and OnSelect should behave differently from each other.

Juha

zeljko
to Juha Manninen
Juha Manninen wrote 12 lines
On tiistai, 22. joulukuuta 2009 16:59:46 zeljko wrote: > It's easy to get delphi behaviour with qt, just write here what is the > right behaviour. Well, I don't remember it and I can't test it now because I don't have Delphi or even Windows in my machine currently. I was working with Delphi for many years. This autumn things changed as I started studying again (as a middle aged man). Anyway, I think OnChange and OnSelect should behave differently from each other.

I must know what's correct way in case of Items.Add(), Items.Clear() etc. Someone got Delphi here ?
Does OnChange() triggers when adding or clearing items ?

Marcin Dębicki
to zeljko
1. on CBN_EDITCHANGE message
2. procedure TCustomCombo.Select;
begin
  if Assigned(FOnSelect) then
    FOnSelect(Self)
  else
    Change;
end;
3. VK_BACK key press
4. function TCustomComboBox.SelectItem(const AnItem: string): Boolean;
var
  Idx: Integer;
  ValueChange: Boolean;
begin
  if Length(AnItem) = 0 then
  begin
    Result := False;
    ItemIndex := -1;
    Change;
    exit;
  end;

Best regards
Marcin D?bicki

2009/12/22 zeljko :

Show quoted text 23 lines
On Tuesday 22 December 2009 16:59, Juha Manninen wrote: > On tiistai, 22. joulukuuta 2009 16:59:46 zeljko wrote: > > It's easy to get delphi behaviour with qt, just write here what is the > > ?right behaviour. > > Well, I don't remember it and I can't test it now because I don't have > Delphi or even Windows in my machine currently. > > I was working with Delphi for many years. This autumn things changed as I > started studying again (as a middle aged man). > > Anyway, I think OnChange and OnSelect should behave differently from each > other. I must know what's correct way in case of Items.Add(), Items.Clear() etc. Someone got Delphi here ? Does OnChange() triggers when adding or clearing items ? _______________________________________________ Qt mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/qt
Luiz Americo Pereira Camara
to zeljko: I must know what's correct way in case of Items.Add(), Items.Clear() etc. Someone got…
zeljko wrote 20 lines
On Tuesday 22 December 2009 16:59, Juha Manninen wrote: > On tiistai, 22. joulukuuta 2009 16:59:46 zeljko wrote: > >> It's easy to get delphi behaviour with qt, just write here what is the >> right behaviour. >> > Well, I don't remember it and I can't test it now because I don't have > Delphi or even Windows in my machine currently. > > I was working with Delphi for many years. This autumn things changed as I > started studying again (as a middle aged man). > > Anyway, I think OnChange and OnSelect should behave differently from each > other. > I must know what's correct way in case of Items.Add(), Items.Clear() etc. Someone got Delphi here ?

Yes.

Does OnChange() triggers when adding or clearing items ?

No. In fact was a bug already fixed in gtk:
http://bugs.freepascal.org/view.php?id=1428

I've made an app to test combobox behavior (attached)

Some (old) discussion about the issue:
http://bugs.freepascal.org/view.php?id=1495

Luiz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ComboBoxItemIndex.zip
Type: application/zip
Size: 2712 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/qt/attachments/20091222/1667608e/attachment.zip>