<Shift>+<Tab> not working?

General FreeBASIC programming questions.
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

<Shift>+<Tab> not working?

Postby skystrick » Jan 02, 2014 4:06

Using FBC 0.91.0 under Linux.

The code for detecting Shift-Tab does not work.

Code: Select all

DO
   CHOICE$ = UCASE$(INKEY$)
   IF CHOICE$ = CHR$(27) THEN GOTO Foo             'Trap <Esc>
   IF CHOICE$ = CHR$(0) + CHR$(15) THEN GOTO Bar   'Trap <Shift>+<Tab>
   IF CHOICE$ = CHR$(13) THEN GOTO Acme            'Trap <Return>
   IF CHOICE$ = CHR$(9) THEN GOTO Corporation      'Trap <Tab>
LOOP


Everything there works except the line for trapping shift-tabbing:

Code: Select all

IF CHOICE$ = CHR$(0) + CHR$(15) THEN GOTO Bar      'Trap <Shift>+<Tab>


Users need to be able to back-tab to jump around form fields.

Thanks!
fxm
Posts: 7270
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: <Shift>+<Tab> not working?

Postby fxm » Jan 02, 2014 8:19

The extended character is Chr(0) only in -lang qb dialect and when the QB form Inkey$ is used, else the extended char is always Chr(255).
See INKEY, paragraph "Dialect Differences".

Are you in -lang qb dialect?
TJF
Posts: 3324
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: <Shift>+<Tab> not working?

Postby TJF » Jan 02, 2014 9:37

... and check your desktop keyboard shortcut settings to make sure that this key combination doesn't get catched before you application.
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 02, 2014 16:18

fxm wrote:The extended character is Chr(0) only in -lang qb dialect and when the QB form Inkey$ is used, else the extended char is always Chr(255).
See INKEY, paragraph "Dialect Differences".

Are you in -lang qb dialect?


Yes, sorry, forgot to mention. I'm always using the QB dialect, and compile as such.
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 02, 2014 16:18

TJF wrote:... and check your desktop keyboard shortcut settings to make sure that this key combination doesn't get catched before you application.


No, it's not being trapped by the desktop.

And regardless, it doesn't work on my serial terminal either. No desktop on that thing! :-)
fxm
Posts: 7270
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: <Shift>+<Tab> not working?

Postby fxm » Jan 02, 2014 19:40

Testing your problem on my PC, I found a weird behavior when executing "inkey$" in a graphic window!

- No problem in a text window when entering "<Shift>+<Tab>".:

Code: Select all

#LANG "QB"

DIM ENTREE AS STRING
DIM I AS INTEGER

SCREEN 0

PRINT "<Esc> to exit."
PRINT
DO
  DO
    ENTREE = INKEY$
  LOOP WHILE ENTREE = ""
  FOR I = 1 TO LEN(ENTREE)
    PRINT USING "CHR$(###)"; ASC(MID$(ENTREE, I, 1));
    IF I < LEN(ENTREE) THEN
      PRINT " + ";
    END IF
  NEXT I
  PRINT
  IF ENTREE = CHR$(27) THEN
    EXIT DO
  END IF
LOOP
PRINT
PRINT "Any key to exit."
SLEEP

Code: Select all

<Esc> to exit.

CHR$(  0) + CHR$( 15)

- Weird behavior in a graphic window when entering "<Shift>+<Tab>".
Two strings are entered in the buffer: "<Shift>+<Tab>" and then "<Tab>":

Code: Select all

#LANG "QB"

DIM ENTREE AS STRING
DIM I AS INTEGER

SCREEN 12

PRINT "<Esc> to exit."
PRINT
DO
  DO
    ENTREE = INKEY$
  LOOP WHILE ENTREE = ""
  FOR I = 1 TO LEN(ENTREE)
    PRINT USING "CHR$(###)"; ASC(MID$(ENTREE, I, 1));
    IF I < LEN(ENTREE) THEN
      PRINT " + ";
    END IF
  NEXT I
  PRINT
  IF ENTREE = CHR$(27) THEN
    EXIT DO
  END IF
LOOP
PRINT
PRINT "Any key to exit."
SLEEP

Code: Select all

<Esc> to exit.

CHR$(  0) + CHR$( 15)
CHR$(  9)
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 02, 2014 19:48

fxm wrote:Testing your problem on my PC, I found a weird behavior when executing "inkey$" in a graphic window!


Thanks, but that doesn't answer my question. As I said, INKEY$ is trapping all keys correctly except <Shift>+<Tab>.
fxm
Posts: 7270
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: <Shift>+<Tab> not working?

Postby fxm » Jan 02, 2014 19:53

Can you test my programs when entering "<Shift>+<Tab>" to check the characters entered in the buffer?
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 02, 2014 20:03

fxm wrote:Can you test my programs when entering "<Shift>+<Tab>" to check the characters entered in the buffer?


Sure. Your program works fine for most things. <Return> comes up CHR$(13), <A> comes up CHR$(97). <Tab> comes up CHR$(9)

But <Shift>+<Tab> does nothing. Nothing printed on the screen, not even a blank line. Absolutely no response from the program whatsoever.

Interestingly, <Ctrl>+<Tab> reports just a normal <Tab> --- CHR$(9).
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 26, 2014 17:38

Help, please!

Again, Shift+Tab (backtabbing) DOESN'T WORK.
dkl
Site Admin
Posts: 3155
Joined: Jul 28, 2005 14:45
Location: Germany

Re: <Shift>+<Tab> not working?

Postby dkl » Jan 26, 2014 21:12

Hello,

I just did some debugging and it seems that FB is receiving ESC [ Z from my XFCE terminal when I press Shift+Tab, but FB does not recognize this sequence and ignores it. After some digging through termcap/terminfo stuff I found that it is the back tab key, termcap code bt. That code is not among those handled by FB, see also src/rtlib/unix/io_inkey.c(30). Sure enough, after adding it there it was recognized. I wonder, what scancode should FB use to represent it?

And furthermore, can/should it be supported in other contexts (X11 graphics window, Win32, DOS, etc.)? When testing inside the Linux console (outside X11/XFCE desktop) I noticed that FB just receives &h9 when I press Shift+Tab, same as when just pressing Tab.

Overall there seem to be tons of escape codes that FB doesn't handle. I suppose it only handles some that were specifically chosen to implement certain common keypresses. Maybe FB could pass escape sequences on to the program instead of ignoring them? But this could only be done by returning ESC from Inkey/Getkey, and then the rest of the sequence in further calls, one char at a time, which would break the assumption that each Inkey/Getkey = 1 keypress...
skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jan 26, 2014 22:03

Thanks for looking into this, dhl. I know that in QB,

CHR$(9) is <Tab>
and
CHR$(0) + CHR$(15) is <Shift>+<Tab> (backtab)

Can that scancode be implemented in FB? It would provide compatiblity with existing QB programs.

Looking at that io_inkey.c list you linked, it appears that F11 and F12 are currently unsupported also?
dkl
Site Admin
Posts: 3155
Joined: Jul 28, 2005 14:45
Location: Germany

Re: <Shift>+<Tab> not working?

Postby dkl » Jan 26, 2014 22:36

I think so, at least as far as FB-linux console-mode Inkey/Getkey goes (FB doesn't recognize the escape sequences that Linux console/XFCE terminal sends for F11/F12, and actually my XFCE terminal goes fullscreen on F11 instead of passing the key on to the running program but that may be the window manager's fault). Multikey() seems to support F11/F12 though. I didn't test on other systems.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Re: <Shift>+<Tab> not working?

Postby sir_mud » Jan 27, 2014 17:48

Shift tab seems to be handled by the terminal emulator here, multikey works properly though:

Code: Select all

#include once "fbgfx.bi"

while not multikey(fb.SC_ESCAPE)

var x = inkey()

if len(x) > 0 then
    for n as integer = 0 to len(x)-1
        if x[n] = 0 then
            print n & ": NULL"
        else
            print n & ": " & x[n]
        end if
    next
end if
if multikey(fb.SC_TAB) and multikey(fb.SC_RSHIFT) or _
    multikey(fb.SC_TAB) and multikey(fb.SC_LSHIFT) then ? "ST"
sleep 10,1
wend

skystrick
Posts: 96
Joined: May 19, 2013 23:25
Location: Florida

Re: <Shift>+<Tab> not working?

Postby skystrick » Jul 10, 2017 5:06

dkl wrote:Hello,

I just did some debugging and it seems that FB is receiving ESC [ Z from my XFCE terminal when I press Shift+Tab, but FB does not recognize this sequence and ignores it. After some digging through termcap/terminfo stuff I found that it is the back tab key, termcap code bt. That code is not among those handled by FB, see also src/rtlib/unix/io_inkey.c(30). Sure enough, after adding it there it was recognized. I wonder, what scancode should FB use to represent it?


Hi, I am writing another program and would like Shift+Tab functionality for jumping backwards between fields. Is it possible to pick a scancode and implement this please?

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests