*Updated from an original post written by Thom McGrath. Run the project and watch the text change when you hold and release the Option/Alt key. In the Timer subclass, put this code in the KeyDown event: Label1.Value = "You are pressing Option."Īnd in the KeyUp event put this code: Label1.Value = "Normal Text" To test this, add a Label to the Window which will be used to display different text when the Option key is held down. You’ll also want to adjust the period of the timer to something small such as 200 to make sure the events are responsive. Now go to your Window, place a Timer on it and set the super to “OptionTimer” and you can insert code into the events for that timer. Lastly add the Action event handler with the following code: If Keyboard.AsyncAltKey = True And Pressed = False ThenĮlseIf KeyBoard.AsyncAltKey = False And Pressed = True Then Next, add a property “Pressed As Boolean”, an event definition “KeyDown”, and a second event definition “KeyUp” to OptionTimer. Start by creating a new class called “OptionTimer” whose super is “Timer”. Also, the subclass will allow you to call events which can come in handy. Either technique will work, but the subclass creates reusable code, something I always recommend. ![]() The solution is to use a Timer to detect the Option/Alt key, though it could be adapted to read any of the modifier keys.įirst of all, we need to decide whether to create a Timer embedded on a Window, or to create a subclass. The problem is KeyDown/KeyUp does not get called for modifier keys. The goal is to inform the user that option-clicking the button will perform a different task.Īt first glance you might think that simply looking for the option key in a KeyDown event will do the trick. ![]() For example, iTunes changes its “Previous Track” button from a rewind icon to a Genius Shuffle icon when the option key is held down. Perhaps what you see is specific to Windows.Īt any rate you now know where to dig, using the browser developer tools.Sometimes it is necessary, or at least user-friendly, to adjust your interface when the user holds down modifier keys. The Canvas control also has an AllowTabs property that indicates whether pressing Tab selects the next control in the window or sends the Tab keystroke to the Canvas control for processing. This can be done either in code or in the Inspector. That said, I quickly tried to deselect the WebListbox by applying focus to a WebTextField, and never does the WebListbox loses it’s selection on Mac, Chrome browser. In order for a Canvas control to receive the focus, you must set the AllowFocusRing property to True. The Selected class is applied to a tag within the _userrows table to make the blue “selection” bar appear. To put the WebListbox in the same state as when it is clicked, you need to set each cell in a row to the Selected class. That said, I know from another thread you are more or less fluent in JavaScript. That is in fact a pseudo selection, smoke and mirrors. To do that, it uses a Selected class which is applied to an entire row when the user clicks on it. Xojo went to great length to present the user with the closest appearance to the Desktop Listbox. WebListBox does not offer the possibility to edit a cell. It so happens that the underlying html element, the Table, does not accept focus at all in it’s readonly state, and gets focus only when allowed to edit a cell. Your comparison with a read only TextArea unfortunately does not stand. I worked more than a little on the WebListbox to extend it’s features. If the SetFocus method was only for a TextField, it wouldn’t be implemented in the WebControl, right? I think it’s Nicolet:Īs a user, wouldn’t you get tired of always clicking the listbox you were at when you get back to the main page after a dialog closes? And users may just get confused that they cannot continue the workflow (using the up/down keys to select another row, for instance). So the user has to click on the listbox to set the focus back to where it was, which is not good. When the dialog is closed, the listbox loses its focus (probably because the button takes it, but it doesn’t matter). ![]() Here’s my problem: I have a WebListBox and a button. Having the focus doesn’t mean a text is being edited, just navigated. I don’t want a focus to edit the control, so, in my opinion, both the TextField and the ListBox should behave the same (have a focus ring and handle keys such as the arrows). Likewise, the Desktop Listbox does not really get the focus unless you make cells or columns editable. But yet, it is not a focus as you would get with a WebTextField, for instance. You get the selection bar only by clicking on it. About the Weblistbox, it does not really get the focus.
0 Comments
Leave a Reply. |