How do we block the tab key?
//this handler is not executed on simulator, maybe because it is supported only in Desktop and Web?
on tabKey
end tabKey
What I want is, when a user pressed tab key, it should not add any space. Pressing tab in development does not add add space but when I ran it in iPad simulator 8.2, it adds space when tab is pressed.
The rawKeyDown message should do what you want.
on rawKeyDown theKey
if theKey is not 65509 then
pass rawKeyDown
end if
end rawKeyDown
Related
I am looking for a way to allow a user to complete a Dialog entry using keyboard shortcuts. Is this possible?
Other questions have discussed assigning shortcuts to the options in an AppleScript dialog box, but not to the "Continue"/"Okay" etc. button.
The main difficulty is that I'm using a multi-line text entry form, so the Enter button simply creates a new line, instead of targeting the default button as it would conventionally. I'm hoping cmdenter can be assigned to the default button instead.
The line of script defining the dialog in question is:
set theResponse to display dialog "Enter tasks:" default answer "
" buttons {"Cancel", "Continue"} default button "Continue"
Running your AppleScript code from Script Editor on a US English MacBook Pro, whether or not something is typed in, fnenter presses the Continue button.
The same keyboard shortcut works on an US English Apple Magic Keyboard when connected to the MacBook Pro and I'd assume any US English Mac it was connected to would do the same. I only have the MacBook Pro to test with at the moment.
In macOS, by default, pressing the tab key in this use case will not move between the controls as the controlling setting in System Preferences > Keyboard > Shortcuts is not set to allow it to act on all controls.
You must select one of the following options, depending on the version of macOS one is running, in order to use the tab key on all controls.
If you see:
Full Keyboard Access: In windows and dialogs, press Tab to move keyboard focus between:
(•) Text boxed and lists only
( ) All Controls
Select: (•) All Controls
If you see:
[] Use keyboard navigation to move between controls
Press the Tab key to move focus forward and Shift Tab to move focus backward.
Check: [√] Use keyboard navigation to move between controls
With this done, one can then use tabtabenter to press the continue button, with the dialog box produced by the code shown in the OP.
Side Note: One can also try fncommandenter as that was necessary from within a VMware macOS Catalina virtual machine that I also tested in.
⌘-Enter (on the numeric keypad) presses Continue
If you are in a multiline text field, hit the Tab key so that focus is on some element other than the text field. Then the Enter key should route properly to the dialog's default close button.
I am working on a livecode application for Android, iPhone, Windows. I would like to add a scroller to a group. So I set vertical scroller of group to true and it worked with a vertical scroll bar on the right nicely for Windows. But when testing it for Android there still a vertical bar for scrolling, I was assuming it may automatically work like a fundamental scroller as it comes with android.
I would like to add a touch scroller instead of a vertical scroller for Android and Iphone. How i can do that?
This lesson explains how to create a native scroller for a text field. However, this method can be implemented on any group-
http://lessons.runrev.com/s/lessons/m/4069/l/94412-creating-a-native-scroller-to-scroll-a-field
With my apologies to the original author, for the lack of attribution, here is some script that will allow scrolling of groups on both desktop and mobile platforms, and does not use the native iOS or Android scrolling "overlays":
local allowMove
on mouseDown
put mouseH(),mouseV() into allowMove
end mouseDown
on mouseMove X,Y
if allowMove is not empty then
lock screen
if the hScrollbar of me then
set the hScroll of me to the hScroll of me + (item 1 of allowMove-X)
end if
if the vScrollbar of me then
set the vScroll of me to the vScroll of me + (item 2 of allowMove-Y)
end if
put X into item 1 of allowMove
put Y into item 2 of allowMove
unlock screen
end if
end mouseMove
on mouseUp
put empty into allowMove
end mouseUp
on mouseRelease
mouseUp
end mouseRelease
The original script has been modified slightly by me to allow scrolling only if the corresponding scrollbars are visible. This makes it very quick and easy to enable or disable scrolling in different directions. I use this for prototyping.
If I instantiate a popup button, I can dismiss it by selecting one of the options or by clicking somewhere else. Is there a good way to dismiss it from a script? I tried setting the menuHistory, but it doesn't seem to have any effect.
Mark - if you check the openStacks is the first line empty while the popup menu is displayed? I think it is and then you could test that way.
Answering my own question:
I haven't found a good way to determine whether a popup menu button is displayed yet - none of the usual property checks seem to work. But I sidestepped the issue thusly:
in my scrollwheel handler I
dispatch "menuPick" to button "PluginMenu"
Then in the menuPick handler of the PluginMenu button I have
if pItemName is empty then
lock screen
put word 2 of the selectedline of field "xyzzy" into tLine
select after line tLine of field "xyzzy"
click at the selectedloc
unlock screen
end if
where pItemName is the normal menuPick parameter.
If I could determine when the popup was visible I could limit the menuPick call to just the times when it's on screen, but otherwise the effect is just to click at the end of the line, deselecting the popup if it's on top.
Edit: the scrollwheel handler mentioned above is in the rawKeyUp handler of field "xyzzy".
Edit 2: as mentioned, that should be "rawKeyDown" instead of "rawKeyUp".
And as Trevor mentioned, checking line 1 of the openStacks makes it even better:
if line 1 of the openStacks is empty then
dispatch "menuPick" to button "PluginMenu"
end if
It may be that you need to fake your popup menu with a palette stack which closes on suspendStack. That way there's no blocking involved and you can close it whenever you like. You would need to mess with the focus of the field I think after opening the palette so it still has the focus.
I just tried clicking a button containing the following script then clicking on a popup button.
on mouseUp
set the uActive of me to not the uActive of me
if the uActive of me then send "test" to me in 2000 millisecs
end mouseUp
on test
put the millisecs
if the uActive of me then send "test" to me in 2000 millisecs
end test
The popup seems to be modal and blocks the timed routine in the button script. I'm thinking that Monte's idea of faking the popup might be a good one ;)
You can't access already open menus by script. However, on Windows, if you open the popup menu with the popup command in a mouseDown handler, the mouseDown handler will run till the end instantly. If you use a stack panel instead of a regular popup menu, you might be able to close the stack panel by script (I haven't tried this). I don't think that this is possible on Mac OS X because menus block any currently running scripts until the menu closes.
I'm developing an application for Nokia C2 Mobile and I want to handle the soft keys of the keyboard
Attached an image with the button that I want to handle
I have tried Handle KeyPressed and the keycode that returned when I press this button is 0
please what should I do ?
The button pointed is Right Soft Key (RSK). In that picture, they added commands GoTo, Menu and Names. Just like that, add commands to the form. Type the code to handle that event in command listener.
Does anyone know of a way to stop an SWT Browser widget from printing its contents?
In my app, this widget will display confidential files. I cannot block everything, but want to make it as difficult as possible to get information out.
I easily hide the context menu when a user right-clicks, so Print cannot be gotten to in that fashion. I overwrite the clipboard to handle print screen, Ctrl-C and Ctrl-V. But if i hit Ctrl-P, I do not want the print dialog to come up either. Any ideas?
I found a way around my situation. In this app, the admin chooses if the user can print the files or not. There is a menu bar in the app, so if printing is allowed, I add a print item in the menu with Ctrl-P as its hot key.
If printing is not allowed, I set the hot key for one of the menu options to be Ctrl-P and dont add the print option at all in the menu bar. This way it disables the print dialog from ever appearing because Ctrl-P executes a menu item function instead.