LB Booster
« Shift+Tab can not be seen by LBB »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:33am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Shift+Tab can not be seen by LBB  (Read 638 times)
SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Shift+Tab can not be seen by LBB
« Thread started 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
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Shift+Tab can not be seen by LBB
« Reply #1 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.
User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Shift+Tab can not be seen by LBB
« Reply #2 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
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Shift+Tab can not be seen by LBB
« Reply #3 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.
User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Shift+Tab can not be seen by LBB
« Reply #4 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
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Shift+Tab can not be seen by LBB
« Reply #5 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.

« Last Edit: Apr 28th, 2015, 8:21pm by Richard Russell » User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx Re: Shift+Tab can not be seen by LBB
« Reply #6 on: Apr 28th, 2015, 8:55pm »



I see Richard,
It is clear thank you.

Regards
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls