<Shift>+<Tab> not working?

General FreeBASIC programming questions.
Posts: 227
Joined: May 09, 2014 21:19
Location: Argentina

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

Postby xlucas » Jul 26, 2017 15:54

Skystrick, I've posted some time ago about the fact that FB for Linux does not read tons of keys and combinations (including F11 and F12, Shift+Function keys, etc.). Looks like this will take time to fix. I've found two temporary solutions: one is to combine InKey with MultiKey and the other one is to directly read from X using Xlib functions. If you only need Shift+Tab and maybe a couple more special keys, the first option is simpler. If you want everything to be detected, including extended characters, then you should go for the second one.

You can detect Shift+Tab like this:

Code: Select all

Dim mykey As String

  mykey = InKey
  Select Case mykey
     Case Chr(27) : Exit Do 'Escape
     Case Chr(9)
        If MultiKey(2) Or MultiKey(3) Then  'I think scancodes 2 and 3 are the Shift keys
           'Shift+Tab was pressed and we're in Linux
           'Tab was pressed
        End If
     Case Chr(255, 15)
        'Shift+Tab was pressed and we're on DOS or Windows
  End Select

This method is not perfect. For example, if you press Tab and for some reason, the loop does not get to the Inkey part because it's busy with something else and then, when it goes on, you happen to be holding the Shift key, but not the Tab key, it will think you've pressed Shift+Tab. But most of the time, it's OK. So for example, be careful if you're using a delay in your loop to avoid hogging the CPU, because that could cause those combinations not to be detected correctly in this fashion.
Posts: 1922
Joined: Jun 02, 2013 9:27
Location: Switzerland

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

Postby MrSwiss » Jul 26, 2017 16:53

xlucas wrote:Looks like this will take time to fix.
I personally, doubt it very much, that this issue will be addressed, ever.

The main reasons are (not exhaustive/complete):
    1) no further development of FBC, is in sight (probably also bug fixing)
    2) the problem seems to be limited to "deprecated languages modes" only
    (QB, FB-light etc. but, NOT in FB default dialect)
    3) even in case of further development taking place, it'll be very low, on the priority list
Therefore, instead of waiting for a fix, I'd advise to switch to: -lang "fb".
Posts: 227
Joined: May 09, 2014 21:19
Location: Argentina

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

Postby xlucas » Sep 01, 2017 0:46

@MrSwiss... I am indeed using dialect FB. I always use only that one. This problem does extend to this dialect. In fact, I am not sure how FBC behaves about this on the other dialects, as I have not tested that yet. Still, I agree with you that it doesn't look like this will be fixed anytime soon. I've been getting used to using XLib for key input. When I feel very comfortable with it, I'll try to post a good "patch" (in the form of a function overload for InKey, perhaps). I can do that already, but it's not perfect.

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests