Page 1 of 1

Canvas keyboard "KeyBack" & Web explorers

Posted: Tue Jan 12, 2016 12:55 am
by DjPoke
Hello

I have a problem with a canvas keyboard released event.
When i hit the "Back" key, in SB, i do some graphical text stuffs, it works.
But, if i upload my program and type its url, the "Back" key shortcut is used by chrome or mozilla to go back on the last url.

Is there a way to by-pass this key conflict ?
(for example in javascript)

Re: Canvas keyboard "KeyBack" & Web explorers

Posted: Tue Jan 12, 2016 7:31 am
by Fred
Yes, there is a way, you can take a look to this for example: https://craig.is/killing/mice

It's planed to add this to SB somewhen !

Re: Canvas keyboard "KeyBack" & Web explorers

Posted: Tue Jan 12, 2016 11:14 am
by DjPoke
Thanks.

I've tried to do this :

Code: Select all

; Backspace key
! Mousetrap.bind('backspace', function() {
!     if(v_CursorAtArea > 0) {
!         var l = v_Ar(v_CursorAtArea).text.length();
!         if(l > 0) {
!             v_Ar(v_CursorAtArea).text = v_Ar(v_CursorAtArea).text.substring(0, l - 1);
!         }
!     }
! });
But i'm not sure that i access correctly my structure. In SB, i should use : Ar(CursorAtArea)\text
I've replaced antislash by a dot but is it the correct syntax ?

Code: Select all

Structure Area
  x.i  
  y.i  
  w.i  
  h.i  
  text.s
  type.i ; #TString, #TValue
  align.i ; #ALeft, #ACenter
  auto.i ; #Manual, #Auto1, etc...
EndStructure

Global Dim Ar.Area(#AreasNumber)
EDIT:
This does nothing too : v_Ar(v_CursorAtArea).v_text

EDIT2:
If forgot to import the .js library, and when i import it as a .sb file with the "!" symbol before the JS lines, my program crash.
But finally, i've changed all to not have to use the backspace key out of a stringgadget.