LB Booster
Programming >> Compatibility with LB4 >> Shift+Tab can not be seen by LBB
http://lbb.conforums.com/index.cgi?board=compatibility&action=display&num=1430201887

Shift+Tab can not be seen by LBB
Post by SarmedNafi on Apr 28th, 2015, 06:18am

Dear Richard,

please check the following code on both LB and LBB and compare the result on main win after pressing Tab key and Shift+Tab Keys.

Code:
    WindowWidth = 536 : WindowHeight = 446
    UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
    UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
    graphicbox  #main.graphicbox1, 205, 45, 115, 65
Open "Window Title" for Window as #main
    #main "trapclose [quit]"
    #main "font ms_sans_serif 10"
    #main.graphicbox1 "setfocus"
    #main.graphicbox1 "when characterInput [go]"   ' Wait for a keyboard entry.
wait
[go]
    Char$= Inkey$
    if Char$=chr$(9) then  ' Tab
    print "Tab"
    Else
    if (len(Char$)=2) AND (asc(right$(Char$,1))=7) then '  Shift + Tab
    print "Shift + Tab"
    end if
    end if
  Wait
[quit]
    close #main : END

 


Thanks a lot
Sarmed
Re: Shift+Tab can not be seen by LBB
Post by Richard Russell on Apr 28th, 2015, 1:23pm

on Apr 28th, 2015, 06:18am, SarmedNafi wrote:
Please check the following code on both LB and LBB and compare the result on main win after pressing Tab key and Shift+Tab Keys.

LB 4.04 has a bug, and it is not one which I have tried to emulate in LBB. When you press Shift+Tab the following Inkey$ string should be generated, according to the docs (this is what LBB generates):

Code:
chr$(4) + chr$(9) 

The 4 indicates that shift was pressed, and the 9 is the virtual key code for the Tab key.

For some strange reason what LB 4.04 actually generates is this:

Code:
chr$(4) + chr$(7) 

The shift key is correctly indicated, but the 7 is wrong.

In this particular case I felt it was better to generate the correct data, as documented, rather than to emulate the bug. However that does inevitably result in the possibility of incompatibility.

Fortunately it is easy to write a program which responds to both the correct and incorrect Inkey$:

Code:
    WindowWidth = 536 : WindowHeight = 446
    UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
    UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
    graphicbox  #main.graphicbox1, 205, 45, 115, 65
    open "Window Title" for Window as #main
    #main "trapclose [quit]"
    #main "font ms_sans_serif 10"
    #main.graphicbox1 "setfocus"
    #main.graphicbox1 "when characterInput [go]"   ' Wait for a keyboard entry.
    wait

[go]
    select case Inkey$
      case chr$(0) + chr$(9): print "Tab"
      case chr$(4) + chr$(9): print "Shift + Tab" ' LBB (correct)
      case chr$(4) + chr$(7): print "Shift + Tab" ' LB4 (incorrect)
    end select
    wait
[quit]
    close #main 
    end 

Richard.
Re: Shift+Tab can not be seen by LBB
Post by SarmedNafi on Apr 28th, 2015, 4:56pm

Quote:
it was better to generate the correct data, as documented


Thank you Richard,

Where it was documented, can you please point to a course or a link.

Regards
Re: Shift+Tab can not be seen by LBB
Post by Richard Russell on Apr 28th, 2015, 5:47pm

on Apr 28th, 2015, 4:56pm, SarmedNafi wrote:
Where it was documented, can you please point to a course or a link.

In the LB 4.04 help under 'Keywords in Alphabetical Order... Inkey$', where it says this:

"When a key is pressed, the information is stored in the variable Inkey$. This special variable holds either a single typed character or multiple characters including a Windows virtual keycode.... If Inkey$ holds more than one character, the first character will indicate whether the Shift, Ctrl, or Alt keys was depressed".

You can find the relevant Virtual Keycode as follows:

Code:
    print _VK_TAB 

which will print 9 (not 7!).

If it's not already there, perhaps somebody would add this bug to the Liberty BASIC Bug Tracker Wiki.

Richard.

Re: Shift+Tab can not be seen by LBB
Post by SarmedNafi on Apr 28th, 2015, 7:45pm

I think the following is the reference by MS

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx

They indicates that 0x07 is undefined so Carl use it, I think it is up to the programmer.

Regards
Re: Shift+Tab can not be seen by LBB
Post by Richard Russell on Apr 28th, 2015, 8:20pm

on Apr 28th, 2015, 7:45pm, SarmedNafi wrote:
I think it is up to the programmer.

No it is not. The LB 4.04 docs say that the second character is the Virtual Keycode of the key that was pressed. In this case the key pressed was the Tab key, for which the Virtual Keycode is VK_TAB (9).

Also note that when the Tab key is pressed on its own (without the shift key) both LB4 and LBB set Inkey$ to:

Code:
chr$(0) + chr$(9) 

So in this case the correct code is used by LB4. If you think Carl deliberately chose to use the wrong code, why didn't he use it for this case as well?

In my opinion it's a bug in LB 4.04, pure and simple.

Richard.


Re: Shift+Tab can not be seen by LBB
Post by SarmedNafi on Apr 28th, 2015, 8:55pm



I see Richard,
It is clear thank you.

Regards