Shoutbox

Cancelling/Inhibiting the default action of the TAB key? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Cancelling/Inhibiting the default action of the TAB key? (/showthread.php?tid=69570)

Cancelling/Inhibiting the default action of the TAB key? by asdf007 on 12-16-2006 at 07:09 PM

Hi everyone :),

I've been working on a little script for the past few days and I've got a little problem. I'm catching the TAB (keyCode == 0x09) key within OnEvent_ChatWndEditKeyDown, and that works pretty well, but I'd also like to inhibit the default behaviour of the key (which will transfer the focus to the next control in the chat window right after OnEvent_ChatWndEditKeyDown is executed).

I'm quite a newbie when it comes to Windows API, so I've got no idea whether it's possible or not (that would be done through the InterOp object, I guess).

Another solution I was thinking about was to simulate a "shift+TAB" in the OnEvent_ChatWndEditKeyDown function, so that the actual TAB just reverses the focus back to the edit area. If that makes sense. That'd be quite tricky but oh well, anything would be fine. :P

Anyone have an idea?

edit: of course, I've tried returning true within OnEvent_ChatWndEditKeyDown. Doesn't work with TAB though. :(


RE: Cancelling/Inhibiting the default action of the TAB key? by Spunky on 12-17-2006 at 01:19 AM

Try using:

code:
function OnEvent_ChatWndEditKeyDown(ChatWnd, KeyCode, CtrlKeyDown, ShiftKeyDown){
        if(KeyCode==0x09){
                KeyCode=0; //also try null or another value
        }
}



Tested it myself :S

I think Windows determines the function of the tab key and so you cannot stop it from sending the "TAB" message. It does say on MSDN that the tab key cannot be used as a hotkey, quite possibly for this reason

BTW - You should also check the state of CtrlKeyDown and ShiftKeyDown so you don't block Ctrl+Key or Shift+Key (if you don't already ;))