mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 14:56:13 +02:00
carbon: implement keyboard processing before menu fire event (LCL compatible). fixes #17205 and probably some other issues
git-svn-id: trunk@27207 -
This commit is contained in:
parent
8615b73bd3
commit
c9c3967f42
@ -84,7 +84,6 @@ type
|
||||
|
||||
function CheckMenu(const Menu: HMENU; const AMethodName: String; AParamName: String = ''): Boolean;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -769,6 +768,5 @@ begin
|
||||
Result:=AnsiChar(KeyValue);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
@ -205,7 +205,7 @@ begin
|
||||
{ Another possible solution of the problem, is to Post another custom event }
|
||||
{ to the loop, and report LCL about Menu pressed after the event arrives, }
|
||||
{ though it might seem, like interface is lagging }
|
||||
if (HotChar<>#0) then
|
||||
if (CarbonMenu.Parent.Dismissed<>kHIMenuDismissedBySelection) and (HotChar<>#0) then
|
||||
begin
|
||||
AllowMenu := True;
|
||||
Focused:=GetFocus;
|
||||
@ -215,17 +215,22 @@ begin
|
||||
if not AllowMenu then
|
||||
begin
|
||||
Result:=eventNotHandledErr;
|
||||
CarbonMenu.Parent.Dismissed:=0;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
FillChar(Msg, SizeOf(Msg), 0);
|
||||
Msg.msg := LM_ACTIVATE;
|
||||
CarbonMenu.LCLMenuItem.Dispatch(Msg);
|
||||
|
||||
Result := noErr;
|
||||
Exit;
|
||||
if CarbonMenu.Parent.Dismissed=kHIMenuDismissedBySelection then begin
|
||||
FillChar(Msg, SizeOf(Msg), 0);
|
||||
Msg.msg := LM_ACTIVATE;
|
||||
CarbonMenu.LCLMenuItem.Dispatch(Msg);
|
||||
CarbonMenu.Parent.Dismissed:=0;
|
||||
Result := noErr;
|
||||
Exit;
|
||||
end else
|
||||
Result:=CallNextEventHandler(ANextHandler, AEvent);
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -36,7 +36,7 @@ uses
|
||||
// widgetset
|
||||
WSControls, WSLCLClasses, WSProc,
|
||||
// LCL Carbon
|
||||
CarbonDef, CarbonGDIObjects,
|
||||
CarbonDef, CarbonGDIObjects, CarbonMenus,
|
||||
// LCL
|
||||
LMessages, LCLMessageGlue, LCLProc, LCLType, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, Menus;
|
||||
|
@ -19,6 +19,24 @@
|
||||
// H A N D L E R S
|
||||
// ==================================================================
|
||||
|
||||
|
||||
procedure SendMenuActivate(AMenu: MenuRef; MenuIdx: MenuItemIndex);
|
||||
var
|
||||
CarbonMenu : TCarbonMenu;
|
||||
Msg : TLMessage;
|
||||
S : ByteCount;
|
||||
begin
|
||||
if GetMenuItemProperty(AMenu, MenuIdx, LAZARUS_FOURCC,
|
||||
WIDGETINFO_FOURCC, SizeOf(TCarbonMenu), S, @CarbonMenu) = noErr then
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), 0);
|
||||
Msg.msg := LM_ACTIVATE;
|
||||
CarbonMenu.LCLMenuItem.Dispatch(Msg);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Name: CarbonWindow_Close
|
||||
------------------------------------------------------------------------------}
|
||||
@ -679,6 +697,9 @@ const
|
||||
KeyMsg: TLMKeyDown;
|
||||
CharMsg: TLMChar;
|
||||
OrigChar: AnsiString;
|
||||
|
||||
Menu: MenuRef;
|
||||
MenuIdx: MenuItemIndex;
|
||||
begin
|
||||
Result:=EventNotHandledErr;
|
||||
{$IFDEF VerboseKeyboard}
|
||||
@ -778,10 +799,15 @@ const
|
||||
if CharMsg.CharCode<>ord(KeyChar) then
|
||||
LCLCharToMacEvent(Char(CharMsg.CharCode));
|
||||
|
||||
|
||||
if Result<>noErr then
|
||||
Result:=CallNextEventHandler(ANextHandler, AEvent);
|
||||
|
||||
if IsMenuKeyEvent(nil, GetCurrentEvent, kMenuEventQueryOnly, @Menu, @MenuIdx) then
|
||||
begin
|
||||
// re-handling menu
|
||||
SendMenuActivate(Menu, MenuIdx);
|
||||
end;
|
||||
|
||||
//Send a LM_(SYS)CHAR
|
||||
if IsSysKey then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user