Handling keypresses in multiple weblistboxes

Hi.

I know the weblistbox doesn’t handle keypresses. I have a problem where I have two listboxes in the same page (three, actually, but I don’t worry about one of them for the time being).

I know the page itself has a keypress event. I think it should be possible to handle focus on listboxes by changing the style of the unfocused/focused listboxes so the arrow keys work in them. I haven’t tried it but would something like this happen? Would keypresses in textareas or input fields “bleed” onto the page event and activate the listboxes? Can “tab” be caught so the element selection is handled by the program and not the browser?

Alternatively, one of my lists could be disguised as a table so users don’t expect it to be clicable. I imagine I can style a listbox to look like a static list of links rather than a listbox.

I’m probably asking obvious questions. It’s my first day with the web target and I’m figuring out limitations to what I’m used to in desktop editions.

Arrow keys can be caught at the page level, or with some JavaScript, at the window.body level.

However, Internet Explorer does not do it properly. In fact, it does not honor KeyPressed at all for arrow keys. So you must catch the keyDown event in JavaScript.

[quote=304481:@Michel Bujardet]Arrow keys can be caught at the page level, or with some JavaScript, at the window.body level.

However, Internet Explorer does not do it properly. In fact, it does not honor KeyPressed at all for arrow keys. So you must catch the keyDown event in JavaScript.[/quote]

Hmm. Ok. I thought I was being clever by faking focus on the weblistboxes :slight_smile:

Well, it is quite feasible. Actually, you can even fake the focus ring with a blue border. It is that pesky IE that makes it more difficult.

Here is some JQuery code from a couple years ago to send the arrow keys to the HashTag :

ExecuteJavaScript(" $(document).keydown(function(e) { if (e.keyCode == 37 || e.keyCode == 38 || e.keyCode==39 || e.keyCode==40 )"+_ " { window.location.replace('#'+'kycde'+(e.keyCode));} }) ; ")

You can return the keys more elegantly to the app with a WebSDK control and Xojo.TriggerServerEvent, but the principle remains the same.