Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

Problem with onkeydown

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

hello

I have made a program with Lazarus. This application make some work according to key pressed from the numpad and function key. It work fine on win32 but i have a big problem with linux-gtk2

the action on a key is handled by the OnKeyDown event but on linux, the input in a modal windows is returned in onkeydown from parent and fire the event when return to parent windows.
I have tried to disable onKeyDown before showing the modal windows with OnKeyDown := nil

and enabling after closing modal windows but the input from modal windows is handled by onkeydown

I have try to clear event like when the programm was buid with delphi using

While PeekMessage(Msg, 0, LM_KEYFIRST, LM_KEYLAST,1) do

but this not work

is there a way to clear the keyboard input after the input key is process

my development to port this application to linux is blocked by this problem and i have found no solution

many thanks for answer and sorry for my bad english

Reply by email

zeljko
to Unknown author
Show quoted text 27 lines
hello I have made a program with Lazarus. This application make some work according to key pressed from the numpad and function key. It work fine on win32 but i have a big problem with linux-gtk2 the action on a key is handled by the OnKeyDown event but on linux, the input in a modal windows is returned in onkeydown from parent and fire the event when return to parent windows. I have tried to disable onKeyDown before showing the modal windows with OnKeyDown := nil and enabling after closing modal windows but the input from modal windows is handled by onkeydown I have try to clear event like when the programm was buid with delphi using While PeekMessage(Msg, 0, LM_KEYFIRST, LM_KEYLAST,1) do but this not work is there a way to clear the keyboard input after the input key is process my development to port this application to linux is blocked by this problem and i have found no solution many thanks for answer and sorry for my bad english

It's hard to say what to do without code.
Best would be to attach example here (this is issue opened by you I guess): http://bugs.freepascal.org/view.php?id=17387

zeljko

Reply by email

Unknown author
to zeljko

Selon zeljko :

Show quoted text 41 lines
On Thursday 16 September 2010 02:30, wrote: > hello > > I have made a program with Lazarus. This application make some work > according to key pressed from the numpad and function key. It work fine on > win32 but i have a big problem with linux-gtk2 > > the action on a key is handled by the OnKeyDown event but on linux, the > input in a modal windows is returned in onkeydown from parent and fire the > event when return to parent windows. > I have tried to disable onKeyDown before showing the modal windows with > OnKeyDown := nil > > and enabling after closing modal windows but the input from modal windows > is handled by onkeydown > > I have try to clear event like when the programm was buid with delphi using > > While PeekMessage(Msg, 0, LM_KEYFIRST, LM_KEYLAST,1) do > > but this not work > > is there a way to clear the keyboard input after the input key is process > > my development to port this application to linux is blocked by this > problem and i have found no solution > > many thanks for answer and sorry for my bad english It's hard to say what to do without code. Best would be to attach example here (this is issue opened by you I guess): http://bugs.freepascal.org/view.php?id=17387 zeljko -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

thank for your answer

here is my onkeydown handler

Procedure TFmain.FormKeyDown(Sender: TObject; Var Key: Word; Shift:
TShiftState);
Var
  numTouche: integer;
Begin
  if sender = Fmain then
  begin
       If Not act Then
          exit;
       numTouche := 0;
       Case key Of
            VK_1..VK_9:
            Begin
                  numTouche := key - 35;
                  cmd(key,numTouche);
                  exit;
            End;
            219:
            begin
                 cmd(Key,23);
                 exit;
            end;
            187:
            begin
                 cmd(key,24);
                 exit;
            end;
            VK_F1..VK_F12:
            Begin
                 numTouche := key - 111;
                 cmd(key, numTouche);
                 exit;
            End;
            VK_NUMPAD0..VK_NUMPAD9, VK_RETURN, VK_DIVIDE, VK_MULTIPLY, VK_ADD,
VK_SUBTRACT, VK_DECIMAL,
            VK_ESCAPE, VK_OEM_PERIOD:
            begin
                 cmd(key,0);
                 exit;
            End;
       end;
 end
End;

the cmd() function process the key and button on screen (for touchscreen and mouse) with button on screen no problem but from keyboard the FormKeydown is process many time after this code

here is a fragment of the function cmd() code

K_F1..VK_F12:
                      Begin
                        // remise a zero panel des erreurs
                        If Ferror = true Then
                          st.Caption := '';
                        // pas de ticket en cours : erreur
                        If Not Fticket Then
                        Begin
                             erreur(ERR_NOTICKET);
                             exit;
                        End;
                        if  FmultiPaiement then
                        begin
                            erreur (ERR_MULTI);
                            exit;
                        end;
                        //le prix n'a pas ?t? saisi
                        If Not Fprix Then
                        Begin
                             erreur(ERR_NOPRIX);
                             exit;
                        End;
                        // touche non programm?
                        If (BtnArray[numTouche].Enabled = false) Then
                        Begin
                                erreur(ERR_NOPROGRAMME);
                                exit;
                        End;
                        LcdLabel.Caption := BtnArray[numTouche].hint;
                        prix := trim(LcdNombre.Caption);
                        dep := LcdLabel.Caption;
                        insere_grille(dep, prix);
                        TotalEnCours(prix, true);
                        // imprime la ligne si une imprimante est active
                        If FescposImprime Then
                        Begin
                             escpos.Add(ticket_formate(dep,prix, InfoEscPos.
                             escpos.PrintLn;
                        End;
                        liste_ajout(dep, prix);
                        Fdepartement := false;
                        Fprix := false;
                        Fsoustotal := false;
                        if extra then
                        begin
                           onKeydown := nil;
                           fextra.showmodal;
                           onkeydown := @FormKeyDown;
                        end;
                        EmptyKeyQueue;
                        exit;
                      End;

returning from fextra.showmodal, refire Onkeydown if close the modal form with the result of the fextra input

fextra is only a form with a Tedit. I have try with an input function but same result

emptykeyqueue is code like in my fist post that clear key message

thanks

Reply by email