New topic: Windows key press not intercepted by return true
<http://forums.realsoftware.com/viewtopic.php?t=47912> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message bobjtls Post subject: Windows key press not intercepted by return truePosted: Sat May 18, 2013 12:41 am Joined: Wed Nov 08, 2006 6:25 pm Posts: 43 Location: Sydney, Australia I have a simple method on a TextArea looking for a particular keyboard event, for example CNTRL & p on Windows, Apple & P on Macs. if TargetWin32 then if KeyBoard.ControlKey then if KeyBoard.AsyncKeyDown(&h23) then //CNTRL & p StartMovieatTime elseif KeyBoard.AsyncKeyDown(&h22) then//CNTRL & i MarkAsInterjection elseif KeyBoard.AsyncKeyDown(&h0E) then //CNTRL & e markeventType("event") end if return true end if else if KeyBoard.OSKey then //keyboard shortcuts select case Key case "i" MarkAsInterjection case "e" markeventType("event") case "p" StartMovieatTime end select return true end if end if This code works perfectly on macs, intercepting the keyboard event and not passing it to the OS. On Windows, the event is intercepted and calls the markaseventtype method but also continues to the TextArea of which this is a method. So, CNTRL & e, calls the markeventType method but also centres the line in which the cursor is. So, the return true is not stopping the keyboard event from being actioned by Windows/RealStudio. Anybody seen this also? Any way around? bobj _________________ bobj ----------------------------------- Dr Bob Jansen Turtle Lane Studios Pty Ltd PO Box 26, Erskineville NSW 2043, Australia Ph: +61-414 297 448 Skype: bobjtls http://www.turtlelane.com.au Top DaveS Post subject: Re: Windows key press not intercepted by return truePosted: Sat May 18, 2013 8:08 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4890 Location: San Diego, CA why not do it this way? #IF TargetWin32 THEN if keyboard.Controlkey then // Windows ControlKey #ELSE if KeyBoard.OSKey then //OSX Command Key #ENDIF select case Key case "i" MarkAsInterjection case "e" markeventType("event") case "p" StartMovieatTime end select return true end if end if This should also allow it to work on non-US keyboards (the hex values you specified can change) _________________ Dave Sisemore iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top bobjtls Post subject: Re: Windows key press not intercepted by return truePosted: Sat May 18, 2013 4:34 pm Joined: Wed Nov 08, 2006 6:25 pm Posts: 43 Location: Sydney, Australia Dave, thanks for your advice. Initially I did have the code using the "i', "e" and "p" strings but found that on win8, when I pressed the CNTRL & P combination, for example, and then inspected what key was being passed to the method, I saw that it was not a "p" but some funny glyph. The only way I could get the code to work was to use the hex values, as the reference guide recommended. In any case, the return true did not stop Windows from actioning the CNTRL e to centre the line of text in the textarea as well as performing markasevent method, and CNTRL p bringing up a window for configuring external monitors. bobj _________________ bobj ----------------------------------- Dr Bob Jansen Turtle Lane Studios Pty Ltd PO Box 26, Erskineville NSW 2043, Australia Ph: +61-414 297 448 Skype: bobjtls http://www.turtlelane.com.au Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
