mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
Fixed Bug #8681. Changed Gtk2 ComboBox.OnChange to be delphi compatible
git-svn-id: trunk@10943 -
This commit is contained in:
parent
15c178b0c2
commit
00f7098809
@ -763,6 +763,7 @@ end;
|
|||||||
|
|
||||||
procedure GtkChangedCB(AWidget: PGtkWidget; WidgetInfo: PWidgetInfo); cdecl;
|
procedure GtkChangedCB(AWidget: PGtkWidget; WidgetInfo: PWidgetInfo); cdecl;
|
||||||
begin
|
begin
|
||||||
|
if WidgetInfo^.UserData <> nil then Exit;
|
||||||
LCLSendChangedMsg(TControl(WidgetInfo^.LCLObject));
|
LCLSendChangedMsg(TControl(WidgetInfo^.LCLObject));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -964,9 +965,16 @@ class procedure TGtk2WSCustomComboBox.SetItemIndex(
|
|||||||
const ACustomComboBox: TCustomComboBox; NewIndex: integer);
|
const ACustomComboBox: TCustomComboBox; NewIndex: integer);
|
||||||
var
|
var
|
||||||
P: PGtkWidget;
|
P: PGtkWidget;
|
||||||
|
WidgetInfo: PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
p := GetWidgetInfo(Pointer(ACustomComboBox.Handle))^.CoreWidget;
|
WidgetInfo := GetWidgetInfo(Pointer(ACustomComboBox.Handle));
|
||||||
gtk_combo_box_set_active(PGtkComboBox(p), NewIndex)
|
p := WidgetInfo^.CoreWidget;
|
||||||
|
if gtk_combo_box_get_active(PGtkComboBox(p)) = NewIndex then exit;
|
||||||
|
// to be delphi compatible OnChange only fires in response to user actions not program actions
|
||||||
|
// so we use WidgetInfo^.Userdata as a flag to not signal the OnChange Event
|
||||||
|
WidgetInfo^.UserData := Pointer(1);
|
||||||
|
gtk_combo_box_set_active(PGtkComboBox(p), NewIndex);
|
||||||
|
WidgetInfo^.UserData := Pointer(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomComboBox.SetMaxLength(
|
class procedure TGtk2WSCustomComboBox.SetMaxLength(
|
||||||
@ -1086,15 +1094,18 @@ var
|
|||||||
Index: Integer;
|
Index: Integer;
|
||||||
begin
|
begin
|
||||||
WidgetInfo := GetWidgetInfo(Pointer(AWinControl.Handle));
|
WidgetInfo := GetWidgetInfo(Pointer(AWinControl.Handle));
|
||||||
|
// we use user data to not signal onchange
|
||||||
|
WidgetInfo^.UserData := Pointer(1);
|
||||||
if gtk_is_combo_box_entry(WidgetInfo^.CoreWidget) then begin
|
if gtk_is_combo_box_entry(WidgetInfo^.CoreWidget) then begin
|
||||||
Entry := GTK_BIN(WidgetInfo^.CoreWidget)^.child;
|
Entry := GTK_BIN(WidgetInfo^.CoreWidget)^.child;
|
||||||
gtk_entry_set_text(PGtkEntry(Entry), PChar(AText));
|
gtk_entry_set_text(PGtkEntry(Entry), PChar(AText));
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
// if not an entry it is a readonly list so we will try to comply by matching the text to an item
|
||||||
|
Index := TCustomComboBox(AWinControl).Items.IndexOf(AText);
|
||||||
|
SetItemIndex(TCustomComboBox(AWinControl), Index);
|
||||||
end;
|
end;
|
||||||
|
WidgetInfo^.UserData := nil;
|
||||||
// if not an entry it is a readonly list so we will try to comply by matching the text to an item
|
|
||||||
Index := TCustomComboBox(AWinControl).Items.IndexOf(AText);
|
|
||||||
SetItemIndex(TCustomComboBox(AWinControl), Index);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TGtk2WSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
|
class function TGtk2WSCustomComboBox.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
Loading…
Reference in New Issue
Block a user