Compiled iOS app automatically opens keyboard on start - livecode

I have a program that works correctly in the iOS simulator, but does not work correctly when loaded onto an iOS device (my iPad mini, running iOS 8)
Once the app is launched, the on-screen keyboard automatically opens up. There are no editable fields that are visible on my card. (There is some title text, but the fields are locked.)
I have no commands in preOpenStack, openStack, preOpenCard, etc...
Any advice on how to prevent this?

Apparently, when the card opens, there is a field that gets focus. Perhaps you think a field is locked but it isn't. It can also be a combobox or datagrid that gets focus. Probably, the best way to test this is to run the following script before compiling your app:
on lockFields
repeat with x = 1 to the number of fields
set the lockText of field x to true
end repeat
end lockFields
Run this script once to lock all fields. Now do a test and see if the keyboard shows up. If you have any comboboxes, include them in the script separately, adding something like the following to it:
repeat for each item myItem in "Combobox 1,Combobox 2,Combobox 3"
disable btn myItem
end repeat
Once you know which control is causing the problem, you can add another script to the card:
on enableControls
repeat for each item myItem in "Field A,Field B,Combobox 1,Combobox 2"
enable control myItem
if the name of control myItem contains "field" then
set the lockText of control myItem to false
end if
end repeat
end enableControls
After running this handler, the fields and comboBoxes should be focusable, but the keyboard should not appear.
Important is also that you have no script laying around that creates a native field (which is invisible). If you create such a native field, the keyboard would also appear.

Related

Python 3 / QT Designer - Radio Buttons showing duplicate values in console

I'm using QT designer to try and make a couple of radio buttons with a label that shows which button I've selected in a variable called URL.
I've got the following code so far :
self.radioButton.toggled.connect(self.myradioButton1_function)
self.radioButton_2.toggled.connect(self.myradioButton1_function)
def myradioButton1_function(self):
staging = 'https://staging/URL'
live= 'https://live/URL'
if self.radioButton.isChecked()==True:
URL=staging
if self.radioButton_2.isChecked()==True:
URL=live
self.label.setText("URL is : " +str(URL))
print(URL)
The label display works fine and switches perfectly between live and staging but the problem is with the variable in Python console, when switching between the two buttons - this prints the variable multiple times e.g.
https://staging/URL
https://live/URL
https://live/URL
https://staging/URL
https://staging/URL
https://live/URL
https://live/URL
I want to use the URL variable in another function so need this to store 1 value on selection of a radio button, can you please advise? Many Thanks.
I fixed this by changing the toggled to clicked e.g.
self.radioButton.clicked.connect(self.myradioButton1_function)
self.radioButton_2.clicked.connect(self.myradioButton1_function)

Livecode not recognizing variable value

I’ve built an application in Livecode where there are nine buttons on a card. Eight of the buttons play short music samples and have a variable that holds the number of times the button was pushed. Holding down the mouse button allows the buttons to be dragged around the card as well. The ninth button starts a script that surveys the variables associated with the eight sample buttons and ensures that all the samples have been listened to at least once. The script puts the eight variables into one variable and then checks to see if they are empty. If they are, the script returns an error message prompting them to make sure they have listened to all the samples. The problem I’m having is that this works for all but one of the buttons – the one associated with variable gVar08. If this button has not been pressed, gVar08 remains empty and does not trigger the error message. I can’t figure out why. The scripts associated with the sample button and the evaluation button are provided below.
#Code for music sample button
global gVar08
on mouseDown
wait 30
if the mouseClick then
play audioClip "samples/C1/C1-8ConcertoForViolinStringsAndHarpsichordInGR202IAllegroMolto.wav"
set the filename of image "icn08" to "icons/if_abstract_symbol-03_1571964a.png"
add 1 to gVar08
else
grab me
end if
end mouseDown
#Code assigned to 9th button: Check to see if all samples played at least 1x
global gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08, gErr01
local sClct
on mouseUp
put gVar01, gVar02, gVar03, gVar04, gVar05, gVar06, gVar07, gVar08 into sClct
repeat for each item local in sClct
if local = "" then
answer "Have you listened to all of the samples? Be sure to play them all."
add 1 to gErr01
break
end if
end repeat
end mouseDown
You need a comma and “” after gVar08 in the list. When it is empty, the list ends with 7. Adding a this should always include the last value even if empty.
Since local is a reserved word, have you tried using a different variable?
I couldn't get your Music Sample button code to work, probably due to the mouseClick function within a mouseDown handler not triggering, so I came up with this option:
global gVar08
local sMove
on mouseUp
if sMove then
put empty into sMove
exit to top --Avoids playing the audio and adding 1 to gVar08 on move
end if
play audioClip "samples/C1/C1-8ConcertoForViolinStringsAndHarpsichordInGR202IAllegroMolto.wav"
set the filename of image "icn08" to "icons/if_abstract_symbol-03_1571964a.png"
add 1 to gVar08
end mouseUp
on mouseStillDown
if the mouse is down then
put "true" into sMove
grab me
end if
end mouseStillDown
Hope this helps.
Paul

Element not recognized

Working on Coded UI testing and for scripts developed using Record Capture and playback feature (ctrl +I).
The problem is when the page has sub-menus (e.g. I need to hover over menu link then click sub-menu). When I record and capture element using Ctrl+I and executed a script it recognizes, but when I ran the script for the second time the element gets changed and it's not recognized.
I have tried simple x path utility posted here but coudn't able to use this feature. What would be the problem for always element id's getting changed. How to resolve it ?
Are you sure it isn't a nested object?
See http://executeautomation.com/blog/how-to-identify-all-the-child-elements-within-a-page-in-coded-ui-test-cuit/
You could also try EnsureClickable()
There could few reasons behind not recognizing an element:
List item Element is not visible when you are trying to click on it.
If Type of Parent Element is e.g. winclient then it’s difficult in coded UI to identify its child elements.
There could various solutions, you can try:
First Click on Menu Item and then click on Sub Menu Item, if you are directly clicking on sub menu item in your recorded script, this will make sub menu element visible.
Also you can check the visibility from Coded UI Test Builder-> Add Assertion button then going to UI Control Map, then select the element in tree and click on Refresh. It will show if element is visible or not.
If Ids are changing, then you can various other properties like Name, ClassName, InnerText, ControlType, TagInstance, ControlName etc. whichever is supported by Element.

How do I detect that the ESC key is pressed using Lotus Notes?

When a user presses the ESC key, I need to display a prompt.
How can I do this in Lotus Notes client?
Can you elaborate? Is this for one application, one form or the whole Lotus client? Why would you want to disable the esc key?
In the Queryclose event you can get a handle to the close event. Continue = false will prevent the form from closing:
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
msgbox "the message"
End Sub
** The original question changed (by a moderator) from it's original intent, which asked to detect AND ignore ESC key press in Lotus Notes. **
You need to use the "QueryClose" event (as others have mentioned), but how do you identify a "legitimate" way to close the form ? We need some logic to distinguish between someone actually clicking a button to "legitimately" close the form, and if someone hits the escape key or the "X" button in the window bar.
So, you need to use 2 form events, and an action button to do this.
In the QueryOpen event of the form
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim session As New NotesSession
Call session.SetEnvironmentVar("CloseDoc",0,True)
End Sub
Your QueryClose event needs to look like this
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
Dim session As New NotesSession
Dim iCloseDoc As Integer
iCloseDoc = session.GetEnvironmentValue("CloseDoc", True)
If iCloseDoc <> 1 Then
continue = False
End If
End Sub
And you need to have an action button called "Close", on the form with this in it.
#SetEnvironment("CloseDoc";"1");
#PostedCommand([FileCloseWindow])
The LotusScript alternative looks like this
Sub Click(Source As Button)
Dim ws As New notesUIWorkspace
Dim session As New NotesSession
Call session.SetEnvironmentVar("CloseDoc",1,True)
Call ws.CurrentDocument.Close
End Sub
Now what's going on ? When you open the form, I set an environment variable for "CloseDoc", (QueryOpen event). If the user hits the "ESC" key or even clicks the "X" on the form to close the window the QueryClose event triggers.
When a request to close the form is detected, the QueryClose event then runs. I retrieve the "CloseDoc" environment variable which, in this case is still 0 (zero). If it's not equal to 1 then the close form will be aborted. You can add a messagebox there if you like.
Now the only way for the user to successfully close the form is for them to press the "Close" button. Which first sets the CloseDoc environment variable to 1, then call NotesUIDoc.close(). Although I am not a big fan of environment variables, it is handy in the case as you are able to record user activity without modifying the current document or another document. (That would be even messier, because you would have to clean up temporary documents, or you are forced to make changes to the document which won't work if the user only has reader access to the database or the current document).
This is relatively clean as the control is managed via a discrete envrionment variable that adds no overhead to the database performance and will not get in the way of any other functionality of applications. Some suggestions in the comments advises the use of global variables instead of environment variables and this quite is appropriate if you're using LotusScript exclusively, but if you have a mixture of formula and lotusScript, environment variables are common to both. But it's upto the developer to determine which.
This is one way I have over the years forced the user to click a specific button to close the document, and ignore "ESC" keys or the "X" button int he form window bar without any annoying messages and is free of performance issues.

How to get menu item selected event in Carbon

I'm trying to handle events related to clicking on or pressing enter on a menu item using the Carbon API in OSX (Cocoa is not an option).
I know about EventTypeSpec and kEventClassMenu and i've dug through the header files looking for the relevant kind constant to use, but i'm still a bit confused as to how I respond to the selection of a menu item. Do I need to handle a key down or mouse down event at the same time as a kEventMenuTargetItem? Do I need to handle kEventMenuMatchKey separately for the enter key?
I'm an idiot.. Events caused by menu items are handled by class command. So:
eventTypes[0].eventClass = kEventClassCommand;
eventTypes[0].eventKind = kEventCommandProcess;
will handle menu events.

Resources