mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 06:19:17 +02:00
gtk1+2 intf: key handling: fixed handling result of DeliverMessage, bug #9638
git-svn-id: trunk@18577 -
This commit is contained in:
parent
0d67f9edaa
commit
26b2693ef7
@ -746,22 +746,22 @@ end;
|
|||||||
|
|
||||||
function GTKKeyPress(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
function GTKKeyPress(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
Result := HandleGtkKeyUpDown(Widget,Event,Data,true, True);
|
Result := HandleGtkKeyUpDown(Widget,Event,Data,true,True,'key-press-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTKKeyPressAfter(Widget: PGtkWidget; Event: pgdkeventkey; Data: gPointer): GBoolean; cdecl;
|
function GTKKeyPressAfter(Widget: PGtkWidget; Event: pgdkeventkey; Data: gPointer): GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
Result := HandleGtkKeyUpDown(Widget,Event,Data,false, True);
|
Result := HandleGtkKeyUpDown(Widget,Event,Data,false,True,'key-press-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTKKeyRelease(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
function GTKKeyRelease(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
Result := HandleGtkKeyUpDown(Widget,Event,Data,true, False);
|
Result := HandleGtkKeyUpDown(Widget,Event,Data,true,False,'key-release-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTKKeyReleaseAfter(Widget: PGtkWidget; Event: pgdkeventkey; Data: gPointer): GBoolean; cdecl;
|
function GTKKeyReleaseAfter(Widget: PGtkWidget; Event: pgdkeventkey; Data: gPointer): GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
Result := HandleGtkKeyUpDown(Widget,Event,Data,false, False);
|
Result := HandleGtkKeyUpDown(Widget,Event,Data,false,False,'key-release-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTKFocusCB( widget: PGtkWidget; event:PGdkEventFocus;
|
function GTKFocusCB( widget: PGtkWidget; event:PGdkEventFocus;
|
||||||
|
@ -1858,7 +1858,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function HandleGTKKeyUpDown(AWidget: PGtkWidget; AEvent: PGdkEventKey;
|
function HandleGTKKeyUpDown(AWidget: PGtkWidget; AEvent: PGdkEventKey;
|
||||||
AData: gPointer; ABeforeEvent, AHandleDown: Boolean) : GBoolean;
|
AData: gPointer; ABeforeEvent, AHandleDown: Boolean;
|
||||||
|
const AEventName: PGChar) : GBoolean;
|
||||||
|
// returns CallBackDefaultReturn if event can continue in gtk's message system
|
||||||
{off $DEFINE VerboseKeyboard}
|
{off $DEFINE VerboseKeyboard}
|
||||||
const
|
const
|
||||||
KEYUP_MAP: array[Boolean {syskey}, Boolean {before}] of Cardinal = (
|
KEYUP_MAP: array[Boolean {syskey}, Boolean {before}] of Cardinal = (
|
||||||
@ -1898,7 +1900,7 @@ var
|
|||||||
TargetObj: gPointer;
|
TargetObj: gPointer;
|
||||||
KeyPressesChar: char;
|
KeyPressesChar: char;
|
||||||
|
|
||||||
procedure StopKeyEvent(const AEventName: PChar);
|
procedure StopKeyEvent;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseKeyboard}
|
{$IFDEF VerboseKeyboard}
|
||||||
DebugLn('StopKeyEvent AEventName="',AEventName,'" ABeforeEvent=',dbgs(ABeforeEvent));
|
DebugLn('StopKeyEvent AEventName="',AEventName,'" ABeforeEvent=',dbgs(ABeforeEvent));
|
||||||
@ -1922,6 +1924,12 @@ var
|
|||||||
AEvent^.KeyVal := 0;
|
AEvent^.KeyVal := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DeliverKeyMessage(const Target: Pointer; var AMessage): boolean;
|
||||||
|
begin
|
||||||
|
Result:=DeliverMessage(Target,AMessage)=0;
|
||||||
|
if not Result then StopKeyEvent;
|
||||||
|
end;
|
||||||
|
|
||||||
function CanSendChar: Boolean;
|
function CanSendChar: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -2081,7 +2089,7 @@ var
|
|||||||
{debugln('KeyActivatedAccelerator call TControl.DialogChar');
|
{debugln('KeyActivatedAccelerator call TControl.DialogChar');
|
||||||
if TControl(AComponent).DialogChar(Msg.CharCode) then begin
|
if TControl(AComponent).DialogChar(Msg.CharCode) then begin
|
||||||
debugln('KeyActivatedAccelerator C handled by LCL');
|
debugln('KeyActivatedAccelerator C handled by LCL');
|
||||||
StopKeyEvent('key_press_event');
|
StopKeyEvent;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;}
|
end;}
|
||||||
end;
|
end;
|
||||||
@ -2116,7 +2124,7 @@ var
|
|||||||
|
|
||||||
// send the (Sys)KeyDown message directly to the LCL
|
// send the (Sys)KeyDown message directly to the LCL
|
||||||
NotifyApplicationUserInput(Msg.Msg);
|
NotifyApplicationUserInput(Msg.Msg);
|
||||||
Result := DeliverMessage(TargetObj, Msg) = 0;
|
DeliverKeyMessage(TargetObj, Msg);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
@ -2261,13 +2269,9 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
// send the (Sys)KeyDown message directly to the LCL
|
// send the (Sys)KeyDown message directly to the LCL
|
||||||
NotifyApplicationUserInput(Msg.Msg);
|
NotifyApplicationUserInput(Msg.Msg);
|
||||||
Result := DeliverMessage(TargetObj, Msg) = 0;
|
if DeliverKeyMessage(TargetObj, Msg)
|
||||||
end;
|
and (Msg.CharCode <> Vkey) then
|
||||||
|
StopKeyEvent;
|
||||||
if Msg.CharCode <> Vkey
|
|
||||||
then begin
|
|
||||||
// key was changed by LCL
|
|
||||||
StopKeyEvent('key_press_event');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (not EventStopped) and aBeforeEvent
|
if (not EventStopped) and aBeforeEvent
|
||||||
@ -2288,12 +2292,12 @@ begin
|
|||||||
// send the message directly to the LCL
|
// send the message directly to the LCL
|
||||||
Msg.Result:=0;
|
Msg.Result:=0;
|
||||||
NotifyApplicationUserInput(Msg.Msg);
|
NotifyApplicationUserInput(Msg.Msg);
|
||||||
Result := DeliverMessage(TargetObj, Msg) = 0;
|
|
||||||
|
|
||||||
if Msg.CharCode <> VKey
|
if DeliverKeyMessage(TargetObj, Msg)
|
||||||
|
and (Msg.CharCode <> VKey)
|
||||||
then begin
|
then begin
|
||||||
// key was handled by LCL
|
// key was handled by LCL
|
||||||
StopKeyEvent('key_release_event');
|
StopKeyEvent;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2329,7 +2333,7 @@ begin
|
|||||||
// send the key after navigation keys were handled
|
// send the key after navigation keys were handled
|
||||||
Result := TWinControl(LCLObject).IntfUTF8KeyPress(Character, 1, SysKey);
|
Result := TWinControl(LCLObject).IntfUTF8KeyPress(Character, 1, SysKey);
|
||||||
if Result or (Character = '')
|
if Result or (Character = '')
|
||||||
then StopKeyEvent('key_press_event')
|
then StopKeyEvent
|
||||||
else if (Length(Character) = 1)
|
else if (Length(Character) = 1)
|
||||||
{$IFDEF Gtk1}
|
{$IFDEF Gtk1}
|
||||||
// GTK1 only supports normal ASCII characters (Note: #127 is delete)
|
// GTK1 only supports normal ASCII characters (Note: #127 is delete)
|
||||||
@ -2369,15 +2373,14 @@ begin
|
|||||||
// send the (Sys)Char message directly (not queued) to the LCL
|
// send the (Sys)Char message directly (not queued) to the LCL
|
||||||
Msg.Result:=0;
|
Msg.Result:=0;
|
||||||
Msg.CharCode := Ord(KeyPressesChar);
|
Msg.CharCode := Ord(KeyPressesChar);
|
||||||
Result := DeliverMessage(TargetObj, Msg) = 0;
|
if DeliverKeyMessage(TargetObj, Msg)
|
||||||
|
and (Ord(KeyPressesChar) <> Msg.CharCode)
|
||||||
if Ord(KeyPressesChar) <> Msg.CharCode
|
|
||||||
then begin
|
then begin
|
||||||
// key was changed by lcl
|
// key was changed by lcl
|
||||||
if (Msg.CharCode=0) or (Msg.CharCode>=128)
|
if (Msg.CharCode=0) or (Msg.CharCode>=128)
|
||||||
then begin
|
then begin
|
||||||
// key set to invalid => just stop
|
// key set to invalid => just stop
|
||||||
StopKeyEvent('key_press_event');
|
StopKeyEvent;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
// try to change the key
|
// try to change the key
|
||||||
@ -3533,7 +3536,7 @@ begin
|
|||||||
and (TLMessage(AMessage).Msg <>LM_PAINT)
|
and (TLMessage(AMessage).Msg <>LM_PAINT)
|
||||||
and (TLMessage(AMessage).Msg <>LM_KEYDOWN)
|
and (TLMessage(AMessage).Msg <>LM_KEYDOWN)
|
||||||
and (TLMessage(AMessage).Msg <>LM_KEYUP)
|
and (TLMessage(AMessage).Msg <>LM_KEYUP)
|
||||||
and (TLMessage(AMessage).Msg < CN_KEYDOWN ) then
|
and (TLMessage(AMessage).Msg <CN_KEYDOWN ) then
|
||||||
DebugLn('DeliverMessage ',DbgS(Target),
|
DebugLn('DeliverMessage ',DbgS(Target),
|
||||||
' ',TComponent(Target).Name,':',TObject(Target).ClassName,
|
' ',TComponent(Target).Name,':',TObject(Target).ClassName,
|
||||||
' Message=',GetMessageName(TLMessage(AMessage).Msg));
|
' Message=',GetMessageName(TLMessage(AMessage).Msg));
|
||||||
|
@ -427,7 +427,8 @@ procedure RememberKeyEventWasHandledByLCL(Event: PGdkEventKey;
|
|||||||
function KeyEventWasHandledByLCL(Event: PGdkEventKey;
|
function KeyEventWasHandledByLCL(Event: PGdkEventKey;
|
||||||
BeforeEvent: boolean): boolean;
|
BeforeEvent: boolean): boolean;
|
||||||
function HandleGTKKeyUpDown(AWidget: PGtkWidget; AEvent: PGdkEventKey;
|
function HandleGTKKeyUpDown(AWidget: PGtkWidget; AEvent: PGdkEventKey;
|
||||||
AData: gPointer; ABeforeEvent, AHandleDown: Boolean) : GBoolean;
|
AData: gPointer; ABeforeEvent, AHandleDown: Boolean; const AEventName: PGChar
|
||||||
|
) : GBoolean;
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
@ -65,28 +65,28 @@ function GTK2KeyDown(Widget: PGtkWidget; Event : pgdkeventkey;
|
|||||||
Data: gPointer) : GBoolean; cdecl;
|
Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
//debugln('GTK2KeyDown ',DbgSName(TObject(Data)));
|
//debugln('GTK2KeyDown ',DbgSName(TObject(Data)));
|
||||||
Result := HandleGtkKeyUpDown(Widget, Event, Data, True, True);
|
Result := HandleGtkKeyUpDown(Widget, Event, Data, True, True, 'key-press-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTK2KeyDownAfter(Widget: PGtkWidget; Event : pgdkeventkey;
|
function GTK2KeyDownAfter(Widget: PGtkWidget; Event : pgdkeventkey;
|
||||||
Data: gPointer) : GBoolean; cdecl;
|
Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
//debugln('GTK2KeyDownAfter ',DbgSName(TObject(Data)));
|
//debugln('GTK2KeyDownAfter ',DbgSName(TObject(Data)));
|
||||||
Result := HandleGtkKeyUpDown(Widget, Event, Data, False, True);
|
Result := HandleGtkKeyUpDown(Widget, Event, Data, False, True, 'key-press-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTK2KeyUp(Widget: PGtkWidget; Event : pgdkeventkey;
|
function GTK2KeyUp(Widget: PGtkWidget; Event : pgdkeventkey;
|
||||||
Data: gPointer) : GBoolean; cdecl;
|
Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
//debugln('GTK2KeyUp ',DbgSName(TObject(Data)));
|
//debugln('GTK2KeyUp ',DbgSName(TObject(Data)));
|
||||||
Result := HandleGtkKeyUpDown(Widget, Event, Data, True, False);
|
Result := HandleGtkKeyUpDown(Widget, Event, Data, True, False, 'key-release-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTK2KeyUpAfter(Widget: PGtkWidget; Event : pgdkeventkey;
|
function GTK2KeyUpAfter(Widget: PGtkWidget; Event : pgdkeventkey;
|
||||||
Data: gPointer) : GBoolean; cdecl;
|
Data: gPointer) : GBoolean; cdecl;
|
||||||
begin
|
begin
|
||||||
//debugln('GTK2KeyUpAfter ',DbgSName(TObject(Data)));
|
//debugln('GTK2KeyUpAfter ',DbgSName(TObject(Data)));
|
||||||
Result := HandleGtkKeyUpDown(Widget, Event, Data, False, False);
|
Result := HandleGtkKeyUpDown(Widget, Event, Data, False, False, 'key-release-event');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GTK2KillFocusCB(widget: PGtkWidget; event:PGdkEventFocus;
|
function GTK2KillFocusCB(widget: PGtkWidget; event:PGdkEventFocus;
|
||||||
|
Loading…
Reference in New Issue
Block a user