location of top of keyboard
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 219
- Joined: Mon Dec 05, 2011 5:35 pm
location of top of keyboard
Is it possible to get the location of the top of the keyboard when it pops up?
At the moment I have hard coded a number into the code but I cringe when I see it. I was thinking of changing the bottom of the text field to that of the top of the keyboard so there wouldn't be any hidden text or is there some other way to deal with the situation of preventing the text field from being hidden?
Coffee 16
At the moment I have hard coded a number into the code but I cringe when I see it. I was thinking of changing the bottom of the text field to that of the top of the keyboard so there wouldn't be any hidden text or is there some other way to deal with the situation of preventing the text field from being hidden?
Coffee 16
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: location of top of keyboard
Hi Coffee
If you use 'effective screenRect' you'll get the area of the screen minus the on-screen keyboard
What follows is an extract from the dictionary entry for screenRect: "Adding the effective adjective to either form returns the area of the screen the application has to itself. In particular, if the keyboard is activated, it take into account if the keyboard is taking up space on the screen. (Android and iOS only)"
If you use 'effective screenRect' you'll get the area of the screen minus the on-screen keyboard
What follows is an extract from the dictionary entry for screenRect: "Adding the effective adjective to either form returns the area of the screen the application has to itself. In particular, if the keyboard is activated, it take into account if the keyboard is taking up space on the screen. (Android and iOS only)"
"...this is not the code you are looking for..."
-
- VIP Livecode Opensource Backer
- Posts: 219
- Joined: Mon Dec 05, 2011 5:35 pm
Re: location of top of keyboard
thanks for the hint.
It all seems so easy and it was working with the hardcoded numbers, but the effective screenRect in the iOS simulator just doesn't want to cooperate
I put this into the field script that I want to have change size, but no go...
I will try again later after I sleep on it.
Maybe it only works on a real device, hmmm...
Coffee16
It all seems so easy and it was working with the hardcoded numbers, but the effective screenRect in the iOS simulator just doesn't want to cooperate
I put this into the field script that I want to have change size, but no go...
Code: Select all
on openField
send "shortenField"
end openField
on closeField
lengthenField
end closeField
on shortenField
--set the rect of me to 0,44,320,248
set the rect of fld "noteEditor" to the effective screenRect
put "short rect:" && the screenRect into fld "noteEditor"
end shortenField
on lengthenField
--set the rect of me to 0,44,320,410
set the rect of fld "noteEditor" to the effective screenRect
put "reg rect:" && the screenRect into fld "noteEditor"
end lengthenField
Maybe it only works on a real device, hmmm...
Coffee16
Re: location of top of keyboard
Wow it's true!
I was playing around with effective blah blah a few weeks ago answering the same question you asked.
I just tested it again and it does what I thought it did.
Now at least on Android I found...
wait for it...
it's neat....
in the openStack makes the focused field move to the top of the screen when the keyboard pops up
No other coding is needed.
Since I haven't seen this documented I don't know if it's just a fluke so I'm not sure it should be relied upon.
Simon
I was playing around with effective blah blah a few weeks ago answering the same question you asked.
I just tested it again and it does what I thought it did.
Now at least on Android I found...
wait for it...
it's neat....
Code: Select all
set the acceleratedRendering of this stack to true

No other coding is needed.
Since I haven't seen this documented I don't know if it's just a fluke so I'm not sure it should be relied upon.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: location of top of keyboard
Coffee
When on a mobile device (or simulator) the keyboardActivated message is sent to the current card as it opens, and the keyboardDeactivated message is sent when the keyboard is closing. The code below calls the effective working screenRect just after the keyboard appears and just after it slides out of view.
The keyboard is activated by clicking on a (non-locked) field and is deactivated by clicking outside the field (the 'mouseDown' handler for the card in the code below sets the focus to nothing if the card [as opposed to a field] is clicked on - something like this is needed or the user will not be able to remove focus from the field and get the keyboard to go away.
In your code, in the keyboardActivated handler write something to allow for the new effective working screenRect by using your shortenfield handler, or use moving, scrolling or some other method - and do the reverse (your lengthenfield handler) when the keyboardDeactived message fires. And of course you get away from using 'hard-coded' sizes by making use of the effective working screenRect in each handler
Good luck!
Simon - I haven't tried your magic coding trick yet but am about to do so
When on a mobile device (or simulator) the keyboardActivated message is sent to the current card as it opens, and the keyboardDeactivated message is sent when the keyboard is closing. The code below calls the effective working screenRect just after the keyboard appears and just after it slides out of view.
The keyboard is activated by clicking on a (non-locked) field and is deactivated by clicking outside the field (the 'mouseDown' handler for the card in the code below sets the focus to nothing if the card [as opposed to a field] is clicked on - something like this is needed or the user will not be able to remove focus from the field and get the keyboard to go away.
In your code, in the keyboardActivated handler write something to allow for the new effective working screenRect by using your shortenfield handler, or use moving, scrolling or some other method - and do the reverse (your lengthenfield handler) when the keyboardDeactived message fires. And of course you get away from using 'hard-coded' sizes by making use of the effective working screenRect in each handler
Code: Select all
on keyboardActivated
answer "keyboard activated" & cr & the effective working screenRect
end keyboardActivated
on keyboardDeactivated
answer "keyboard deactivated" & cr & the effective working screenRect
end keyboardDeactivated
on mousedown
focus on nothing
end mousedown
Simon - I haven't tried your magic coding trick yet but am about to do so

"...this is not the code you are looking for..."
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: location of top of keyboard
Simon
Unfortunately including:
In openStack makes no difference in an iOS simulator when I test it (didn't try Android emulator [life is too short]) 
Dave
Unfortunately including:
Code: Select all
set the acceleratedRendering of this stack to true

Dave
"...this is not the code you are looking for..."