mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:19:17 +02:00
Workaround GTK accelerator bug.
git-svn-id: trunk@797 -
This commit is contained in:
parent
ff5eb49919
commit
65f88cab6d
@ -1119,7 +1119,7 @@ begin
|
|||||||
|
|
||||||
//TBitBtn
|
//TBitBtn
|
||||||
LM_IMAGECHANGED, LM_LAYOUTCHANGED :
|
LM_IMAGECHANGED, LM_LAYOUTCHANGED :
|
||||||
Begin
|
begin
|
||||||
box1 := gtk_object_get_data(pgtkObject(handle),'HBox');
|
box1 := gtk_object_get_data(pgtkObject(handle),'HBox');
|
||||||
if box1 <> nil then
|
if box1 <> nil then
|
||||||
begin
|
begin
|
||||||
@ -1152,11 +1152,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
pStr := Ampersands2Underscore(PChar(TBitBtn(Sender).Caption));
|
pStr := Ampersands2Underscore(PChar(TBitBtn(Sender).Caption));
|
||||||
|
try
|
||||||
pLabel := gtk_label_new(pStr);
|
pLabel := gtk_label_new(pStr);
|
||||||
Accel:= gtk_label_parse_uline(PGtkLabel(pLabel), pStr);
|
Accel:= gtk_label_parse_uline(PGtkLabel(pLabel), pStr);
|
||||||
|
if Accel <> GDK_VOIDSYMBOL then begin
|
||||||
gtk_accel_group_add(gtk_accel_group_get_default, Accel, 0,
|
gtk_accel_group_add(gtk_accel_group_get_default, Accel, 0,
|
||||||
GTK_ACCEL_VISIBLE, PGtkObject(TBitBtn(Sender).Handle), 'clicked');
|
GTK_ACCEL_VISIBLE, PGtkObject(TBitBtn(Sender).Handle), 'clicked');
|
||||||
|
end;
|
||||||
|
finally
|
||||||
StrDispose(pStr);
|
StrDispose(pStr);
|
||||||
|
end;
|
||||||
if (TBitBtn(Sender).Layout = blGlyphLeft)
|
if (TBitBtn(Sender).Layout = blGlyphLeft)
|
||||||
or (TBitBtn(Sender).Layout = blGlyphTop) then
|
or (TBitBtn(Sender).Layout = blGlyphTop) then
|
||||||
begin
|
begin
|
||||||
@ -2066,9 +2071,10 @@ begin
|
|||||||
AccelKey:= gtk_label_parse_uline(pGtkLabel(p), aLabel);
|
AccelKey:= gtk_label_parse_uline(pGtkLabel(p), aLabel);
|
||||||
SetAccelKey(p, AccelKey);
|
SetAccelKey(p, AccelKey);
|
||||||
if AccelKey <> 0 then
|
if AccelKey <> 0 then
|
||||||
gtk_widget_add_accelerator(p, 'grab_focus',
|
writeln('Calling Accel group 2');
|
||||||
gtk_accel_group_get_default(),
|
gtk_widget_add_accelerator(p, 'grab_focus', gtk_accel_group_get_default(),
|
||||||
AccelKey, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
|
AccelKey, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
|
||||||
|
writeln('Called Accel group 2');
|
||||||
finally
|
finally
|
||||||
StrDispose(aLabel);
|
StrDispose(aLabel);
|
||||||
end;
|
end;
|
||||||
@ -2692,13 +2698,26 @@ var
|
|||||||
MsgPtr: PMsg;
|
MsgPtr: PMsg;
|
||||||
Widget: PGtkWidget;
|
Widget: PGtkWidget;
|
||||||
FixWidget: PGtkWidget;
|
FixWidget: PGtkWidget;
|
||||||
|
Accelerators: PGSlist;
|
||||||
|
AccelEntry : PGtkAccelEntry;
|
||||||
begin
|
begin
|
||||||
Handle := hwnd(ObjectToGtkObject(Sender));
|
Handle := hwnd(ObjectToGtkObject(Sender));
|
||||||
if Handle=0 then exit;
|
if Handle=0 then exit;
|
||||||
|
Widget:=PGtkWidget(Handle);
|
||||||
|
|
||||||
|
// Remove control accelerators - has to be done due to GTK+ bug?
|
||||||
|
if Sender is TWinControl then begin
|
||||||
|
Accelerators:= gtk_accel_group_entries_from_object(PGtkObject(Handle));
|
||||||
|
while Accelerators <> nil do begin
|
||||||
|
AccelEntry:= Accelerators^.data;
|
||||||
|
Accelerators:= Accelerators^.next;
|
||||||
|
with AccelEntry^ do
|
||||||
|
gtk_accel_group_remove(accel_group, accelerator_key, accelerator_mods, PGtkObject(Handle));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
RemoveCallbacks(Sender);
|
RemoveCallbacks(Sender);
|
||||||
|
|
||||||
Widget:=PGtkWidget(Handle);
|
|
||||||
FixWidget:=GetFixedWidget(Widget);
|
FixWidget:=GetFixedWidget(Widget);
|
||||||
SetWidgetIsDestroyingHandle(Widget);
|
SetWidgetIsDestroyingHandle(Widget);
|
||||||
|
|
||||||
@ -5221,11 +5240,12 @@ begin
|
|||||||
// Add accelerators
|
// Add accelerators
|
||||||
AccelGroup := GetAccelGroup(ContainerMenu);
|
AccelGroup := GetAccelGroup(ContainerMenu);
|
||||||
AccelKey := GetAccelKey(MenuItem);
|
AccelKey := GetAccelKey(MenuItem);
|
||||||
if (AccelGroup <> nil) and (AccelKey <> 0) then
|
if (AccelGroup <> nil) and (AccelKey <> 0) then begin
|
||||||
gtk_accel_group_add(AccelGroup, AccelKey, GDK_MOD1_MASK,
|
gtk_accel_group_add(AccelGroup, AccelKey, GDK_MOD1_MASK,
|
||||||
GTK_ACCEL_LOCKED, PGtkObject(MenuItem),
|
GTK_ACCEL_LOCKED, PGtkObject(MenuItem),
|
||||||
'activate_item');
|
'activate_item');
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -5685,6 +5705,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.197 2002/09/04 12:57:31 lazarus
|
||||||
|
Workaround GTK accelerator bug.
|
||||||
|
|
||||||
Revision 1.196 2002/09/04 09:32:17 lazarus
|
Revision 1.196 2002/09/04 09:32:17 lazarus
|
||||||
MG: improved streaming error handling
|
MG: improved streaming error handling
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user