gtk2: use 'popup-shown' property listening to identify dropDown and closeUp combobox events under windows

git-svn-id: trunk@12575 -
This commit is contained in:
paul 2007-10-24 06:52:27 +00:00
parent 6afb960278
commit 86b2cfaab0

View File

@ -877,6 +877,22 @@ begin
LCLSendCloseUpMsg(TControl(WidgetInfo^.LCLObject));
end;
procedure GtkNotifyCB(AObject: PGObject; pspec: PGParamSpec; WidgetInfo: PWidgetInfo); cdecl;
var
AValue: TGValue;
begin
if pspec^.name = 'popup-shown' then
begin
FillChar(AValue, SizeOf(AValue), 0); // fill by zeros
g_value_init(@AValue, G_TYPE_BOOLEAN); // initialize for boolean
g_object_get_property(AObject, pspec^.name, @AValue); // get property value
if AValue.data[0].v_int = 0 then // if 0 = False then it is close up
LCLSendCloseUpMsg(TControl(WidgetInfo^.LCLObject))
else // in other case it is drop down
LCLSendDropDownMsg(TControl(WidgetInfo^.LCLObject));
end;
end;
procedure GtkChangedCB(AWidget: PGtkWidget; WidgetInfo: PWidgetInfo); cdecl;
var
LCLIndex: PLongint;
@ -936,6 +952,9 @@ begin
end;
g_signal_connect(ComboWidget, 'changed', TGCallback(@GtkChangedCB), AWidgetInfo);
{$ifdef windows}
g_signal_connect(ComboWidget, 'notify', TGCallback(@GtkNotifyCB), AWidgetInfo);
{$endif}
// First the combo (or the entry)
if gtk_is_combo_box_entry(ComboWidget) then begin
@ -975,7 +994,8 @@ begin
end;
// if we are a GtkComboBoxEntry
if GtkWidgetIsA(PGtkWidget(AEntry), GTK_TYPE_ENTRY) then begin
if GtkWidgetIsA(PGtkWidget(AEntry), GTK_TYPE_ENTRY) then
begin
// Anything?
end;
@ -987,12 +1007,13 @@ begin
and (GTK_IS_MENU(APrivate^.popup_window)) then
AMenu := GTK_OBJECT(APrivate^.popup_window);
if Assigned(AMenu) then begin
if Assigned(AMenu) then
begin
g_signal_connect(AMenu, 'show', G_CALLBACK(@GtkPopupShowCB), AWidgetInfo);
g_signal_connect_after(AMenu, 'selection-done', G_CALLBACK(@GtkPopupHideCB), AWidgetInfo);
end;
//g_signal_connect(ComboWidget, 'popup-shown', TGCallback(@GtkPopupShowCB), AWidgetInfo);
// g_signal_connect(ComboWidget, 'set-focus-child', TGCallback(@GtkPopupShowCB), AWidgetInfo);
g_object_set_data(G_OBJECT(AWidget), 'Menu', APrivate^.popup_widget);
end;