Sign in Join

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

Mailing lists / fpc-pascal / 2007-10

Keyboard unit under Linux

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Frank McCormick

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am having a tough time using the keyboard unit under Linux. Please tell me whats wrong with this code:

( var section cut out)

Begin
   InitKeyBoard;
   Repeat
     K:=pollKeyEvent;
     if k 0
     then
     begin
       k:=getkeyevent;
       k:=translatekeyevent(k);
       if isfunctionkey(k)
       then
       case k Of
       kbdF1 :
            Begin
            End;
       kbdF3 : DoSpot;
       kbdF4 : DoId;
       kbdF2 :Begin
                 End;
       kbdF9 : GetUpdate(PromoString,PromoPrompt);
       kbdF10 : GetUpdate(WeatherString,WeatherPrompt);
      end
      else  if not isfunctionkey(k)
      then
        case getkeyeventchar(k) of
        '1'..'8' :
                  Begin
       'c':
             Begin
             End;
       'd':
             Begin
             End;
       'N','n': GetNext;
      End; {of case}
     End;
  Until quit;
End;
I have chopped out a lot of the code; I never get any of the keys returned, either
on the console or in an xterm under X. I must be missing something obvious :)

Cheers

Frank

- --
Change the world one loan at a time - visit Kiva.org to find out how

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHFlzPzWG7ldLG6fIRAqaFAJ9Z2Z/k8nLcUd5cI+NUlTX/7XXVFACgvu6Z hFwgcq+jvnlzqyZ1Bo11xRQ=
=xd6H
-----END PGP SIGNATURE-----

Reply by email

Frank McCormick

Resending because of some changes in my results.

I am having a tough time using the keyboard unit under Linux. Please tell me whats wrong with this code:

( var section cut out)

Begin
   InitKeyBoard;
   Repeat
     K:=pollKeyEvent;
     if k 0
     then
     begin
       k:=getkeyevent;
       k:=translatekeyevent(k);
       if isfunctionkey(k)
       then
       case k Of
       kbdF1 :
            Begin
            End;
       kbdF3 : ;//DoSpot;
       kbdF4 : ;//DoId;
       kbdF2 :Begin
                 End;
       kbdF9 : ;//GetUpdate(PromoString,PromoPrompt);
       kbdF10 :;// GetUpdate(WeatherString,WeatherPrompt);
      end
      else  if not isfunctionkey(k)
      then
        case getkeyeventchar(k) of
        '1'..'8' :
                  Begin
                  End;
       'c':
             Begin
             End;
       'd':
             Begin
             End;
       'N','n': GetNext;
      End; {of case}
     End;
  Until quit;
End;

I have chopped out a lot of the code; The only keys I get or those in the getkeyeventchar section, i.e. '1'..'8' etc.

Cheers

Frank

---
Change the world one loan at a time - visit Kiva.org to find out how

Reply by email

Michalis Kamburelis
to Frank McCormick
Frank McCormick wrote 20 lines
Resending because of some changes in my results. I am having a tough time using the keyboard unit under Linux. Please tell me whats wrong with this code: ( var section cut out) Begin InitKeyBoard; Repeat K:=pollKeyEvent; if k 0 then begin k:=getkeyevent; k:=translatekeyevent(k); if isfunctionkey(k) then case k Of

Replace above line with "case GetKeyEventCode(k) Of". To compare with constants like kbdF1 and such, you have to extract event code from TKeyEvent value by GetKeyEventCode (somewhat analogous to GetKeyEventChar that you use below).

Show quoted text 36 lines
kbdF1 : Begin End; kbdF3 : ;//DoSpot; kbdF4 : ;//DoId; kbdF2 :Begin End; kbdF9 : ;//GetUpdate(PromoString,PromoPrompt); kbdF10 :;// GetUpdate(WeatherString,WeatherPrompt); end else if not isfunctionkey(k) then case getkeyeventchar(k) of '1'..'8' : Begin End; 'c': Begin End; 'd': Begin End; 'N','n': GetNext; End; {of case} End; Until quit; End; I have chopped out a lot of the code; The only keys I get or those in the getkeyeventchar section, i.e. '1'..'8' etc. Cheers Frank

Reply by email

Frank McCormick
to Michalis Kamburelis
Show quoted text 26 lines
Frank McCormick wrote: > Resending because of some changes in my results. > > > I am having a tough time using the keyboard unit under Linux. Please tell me > whats wrong with this code: > > ( var section cut out) > > Begin > InitKeyBoard; > Repeat > K:=pollKeyEvent; > if k 0 > then > begin > k:=getkeyevent; > k:=translatekeyevent(k); > if isfunctionkey(k) > then > case k Of Replace above line with "case GetKeyEventCode(k) Of". To compare with constants like kbdF1 and such, you have to extract event code from TKeyEvent value by GetKeyEventCode (somewhat analogous to GetKeyEventChar that you use below).

Bingo. That did it. Is it just me or is this keyboard stuff unnecessarily complicated under Linux ?

Thanks for spotting that!!

Cheers

Frank

Change the world one loan at a time - visit Kiva.org to find out how

Reply by email