Focus in Focus
Moderators: heatherlaine, kevinmiller, robinmiller, malte, splash21
-
- VIP Livecode Opensource Backer
- Posts: 114
- Joined: Wed Apr 08, 2009 11:54 pm
- Location: Shellharbour, Australia
Focus in Focus
Hello Forum,
What is the preferred way to focus on MobGUI native iOS controls, like the Text Field?
Thank you in advance.
Kind regards, Andrew
What is the preferred way to focus on MobGUI native iOS controls, like the Text Field?
Thank you in advance.
Kind regards, Andrew
-
- VIP Livecode Opensource Backer
- Posts: 93
- Joined: Tue Nov 17, 2009 6:47 pm
- Location: Wellington, New Zealand
Re: Focus in Focus
Maybe I'm missing the point here ... but just tap on the field? That brings focus and automatically reveals the keyboard.
-
- VIP Livecode Opensource Backer
- Posts: 114
- Joined: Wed Apr 08, 2009 11:54 pm
- Location: Shellharbour, Australia
Re: Focus in Focus
Hello pthirkell,
Perhaps I should have said:
What is the preferred way to programmatically focus on MobGUI native iOS controls, like the Text Field?
I want the focus to be on a particular MobGui generated native iOS field when the card opens, so that the user is not forced to touch the field to attain focus.
I was not sure whether the regular focus command worked, or whether you send a touch to the field (which in fact is a group, and may need to be referenced in a different way), or whether from the release notes you use something like iphoneControlDo id, "focus" etc. Still not sure of the correct way, that's why I asked.
Kind regards, Andrew
Perhaps I should have said:
What is the preferred way to programmatically focus on MobGUI native iOS controls, like the Text Field?
I want the focus to be on a particular MobGui generated native iOS field when the card opens, so that the user is not forced to touch the field to attain focus.
I was not sure whether the regular focus command worked, or whether you send a touch to the field (which in fact is a group, and may need to be referenced in a different way), or whether from the release notes you use something like iphoneControlDo id, "focus" etc. Still not sure of the correct way, that's why I asked.
Kind regards, Andrew
-
- VIP Livecode Opensource Backer
- Posts: 114
- Joined: Wed Apr 08, 2009 11:54 pm
- Location: Shellharbour, Australia
Re: Focus in Focus
Hello Dixie,
Thank you, for your reply. I did try your suggestion earlier - it does not work.
Recipe:
I create a new stack with MobGUI.
I navigate to the Native iOS controls (panel)
I drag on a native text field, and name it 'dixie'
I drag on a standard button, and edit it's script and create a on mouseUp handler:
When I run the stack in the IDE, and click on my button which is to give focus to the native text field, it bombs with the error:
button "Button": execution error at line 2 (Chunk: no such object) near "dixie", char 10.
Dixie, I suspected focus would not work in this manner as we are not dealing with LiveCode IDE fields. In the case of the MobGUI's native iOS text field, we are dealing with a group of objects.
Therefore, I suspect such groups of objects are probably referenced in another manner. I guess that is the heart of the question.
Kind regards, Andrew
Thank you, for your reply. I did try your suggestion earlier - it does not work.
Recipe:
I create a new stack with MobGUI.
I navigate to the Native iOS controls (panel)
I drag on a native text field, and name it 'dixie'
I drag on a standard button, and edit it's script and create a on mouseUp handler:
Code: Select all
on mouseUp
focus on field "dixie"
end mouseUp
button "Button": execution error at line 2 (Chunk: no such object) near "dixie", char 10.
Dixie, I suspected focus would not work in this manner as we are not dealing with LiveCode IDE fields. In the case of the MobGUI's native iOS text field, we are dealing with a group of objects.
Therefore, I suspect such groups of objects are probably referenced in another manner. I guess that is the heart of the question.
Kind regards, Andrew
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Focus in Focus
Andrew...
Apologies... Have a look at page 48 od the iOS release notes. You are able to set the 'enabled' property of the UITextField to true or false as in... iphoneControlSet idOrName, property, value
be well
Dixie
Apologies... Have a look at page 48 od the iOS release notes. You are able to set the 'enabled' property of the UITextField to true or false as in... iphoneControlSet idOrName, property, value
be well
Dixie
-
- VIP Livecode Opensource Backer
- Posts: 114
- Joined: Wed Apr 08, 2009 11:54 pm
- Location: Shellharbour, Australia
Re: Focus in Focus
Thank you for your assistance Dixie,
The solution:
First in response to your comments Dixie:
iosUITextField is enabled by default when dragged onto a card from the MobGUI palette. Therefore there is no requirement to set the iosUITextField to enabled in your code. Should you wish to enable or disable your iosUITextField, you would do so as follows:
Back to the focus of the question, which was programmatically providing focus to a iosUITextField.
Simply:
The reason this did not work for me first time around, is that I experienced some form of corruption with my stack, that prevented the global gInputA from being updated by the creation of each new iosUITextField.
Thanks again, for your comments, and I hope someone else may benefit from this.
Kind regards, Andrew
The solution:
First in response to your comments Dixie:
iosUITextField is enabled by default when dragged onto a card from the MobGUI palette. Therefore there is no requirement to set the iosUITextField to enabled in your code. Should you wish to enable or disable your iosUITextField, you would do so as follows:
Code: Select all
global gInputA
iphoneControlDo gInputA["theNameOfYourIosUITextField"], "enabled", "true"
Simply:
Code: Select all
global gInputA
iphoneControlDo gInputA["theNameOfYourIosUITextField"], "focus"
Thanks again, for your comments, and I hope someone else may benefit from this.
Kind regards, Andrew