Page 1 of 1
SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 12:36 am
by Da_Elf
Trying to run some code when i click on a text field. Currently "on textChanged" works but i also want to do something when i simply click on the field. "on mouseUp" and "on mouseRelease" doesnt work.I'im assuming because its text isnt locked and its focusable.
SOLVED---
On openField works
Re: on FocusIn not working
Posted: Sat Dec 30, 2017 12:49 am
by quailcreek
MouseRelease is sent when the user releases the mouse outside the control that was clicked. Is that what you want?
I'im assuming because its text isnt locked and its focusable.
Very possible.
Re: on FocusIn not working
Posted: Sat Dec 30, 2017 12:54 am
by Da_Elf
No, i just want that when i click on a field it runs something. but when you type it does something else
so it has to have a handler for on textChanged as well as some sort of mouseUp or something for when i click in the field
Re: on FocusIn not working
Posted: Sat Dec 30, 2017 12:59 am
by Da_Elf
So many handlers so little time. found it. i was looking at mouse in the dictionary. i found what i needed under field
On openField works
Re: on FocusIn not working
Posted: Sat Dec 30, 2017 12:59 am
by Klaus
Since mouse-events** are not registered in fields, maybe an "openfield" handler will do?
**Except right-click e.g. to display a popup menu or something.
Re: SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 1:06 am
by dunbarx
In an unlocked field, the only message sent is "openField", and only when the field gains focus. That means that if you click on a field you will get that message. But you will not get it again unless you leave the field, click somewhere else (focus on something else) and click back. So you cannot log successive mouseClicks.
Dare I suggest something like this (in the card script:
Code: Select all
on idle
if the mouse is down then put the seconds
end idle
Aw, why not?
Craig Newman
Re: SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 1:07 am
by quailcreek
Type putting this in the fld.
Code: Select all
on mouseUp pButtonNumber
if the optionKey is down then
answer "Fred"
else
answer "Wilma"
end if
end mouseUp
Re: SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 1:36 am
by dunbarx
Type putting this in the fld.
MouseUp is not sent in an unlocked field.
Craig
Re: SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 5:37 pm
by jacque
See if selectionChanged does what you want.
Re: SOLVED on FocusIn not working
Posted: Sat Dec 30, 2017 7:16 pm
by dunbarx
See if selectionChanged does what you want.
Jacque's idea might handle nearly all your needs. It will not do much if the user clicks in the same place multiple times, though.
Craig
Re: SOLVED on FocusIn not working
Posted: Mon Jan 01, 2018 12:19 am
by Da_Elf
using on openField worked but now i want something to happen when i close field but its not working
the field is focusable and text not locked
i want that when you click on the field you have the option of typing with a keyboard or using my own on screen keyboard which can be accessed by a little keyboard icon that pops up next to the selected field but i cant get the keyboard icon to go away when you focus out of the field
Code: Select all
on openField
set visible of img "onScreenKeyboard" of the owner of me to true
end openField
on textChanged
if (the length of me > 12) or (the number of lines of me > 1) then
delete the last char of me
end if
end textChanged
on closeField
set visible of img "onScreenKeyboard" of the owner of me to false
end closeField
Re: SOLVED on FocusIn not working
Posted: Tue Jan 02, 2018 12:40 am
by jacque
Try adding an exitField handler:
Code: Select all
on exitField
closeField
end exitField
Re: SOLVED on FocusIn not working
Posted: Tue Jan 02, 2018 2:00 am
by Da_Elf
whoohoo. it works. They had something about erasing changes to the field so i didnt think it was what i needed.