Page 1 of 1

hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 11:22 am
by keram
Hi,

I have card with number of buttons labels and fields. One of the fields is for selection of fonts (fld "fonts"). When clicking or tapping on it fonts are selected and the field gets hidden. I'd like to make it possible to hide that field with click/tap outside of it.

I grouped all the objects (except the font field) on that card (grp "settingsGroup") and put the code below on the group level

Code: Select all

on mouseUp
   put the effective rect of fld "fonts" into tHideFonts
   if the mouseH < item 1 of tHideFonts or the mouseH > item 3 of tHideFonts \ 
         or the mouseV < item 2 of tHideFonts or the mouseV > item 4 of tHideFonts then hide fld "fonts"
end mouseUp
+ this code on the card level

Code: Select all

on mouseUp
   send mouseUp to grp "settingsGroup"
end mouseUp
then it works except for the buttons on the card.

I could put the same code in each button on the card, but would prefer to make it with least coding, preferably on one place.

How to make it?

keram

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 11:46 am
by jmburnod
Hi Keram
it works except for the buttons on the card.
Mouserelease ?

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 12:33 pm
by keram
Hi Jean-Marc,

From Dictionary about mouseRelease: "Sent when the user releases the mouse outside the control that was clicked."
So that requires a tap/click on the fld "fonts" to start with and that's what I want to avoid. The user should be able to tap outside the field to hide it.

Thanks anyway.

keram

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 12:52 pm
by Klaus
Hi Keram,

do the buttons in your group have a "mouseup" handler on their own?
If yes, you need to add "pass mouseup" at the end of that handler.


Best

Klaus

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 5:49 pm
by keram
Thanks Klaus,

Yes, they do. In some cases that addition of "pass mouseUp" helped. This is in cases where the handler puts in a text into a field for example. But in cases where there is are command go or answer it does not work. But it's not a big deal, there are just few of these buttons and I can code them individually with this:

Code: Select all

      if  visible of fld "fonts" of cd "settingsandfiles" is true then
      put the effective rect of fld "fonts" into tHideFonts
      if the mouseH < item 1 of tHideFonts or the mouseH > item 3 of tHideFonts \ 
            or the mouseV < item 2 of tHideFonts or the mouseV > item 4 of tHideFonts then hide fld "fonts"
      exit mouseUp to top
   end if
keram

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 5:56 pm
by Klaus
Hi Keram,

Code: Select all

exit mouseUp to top
Either:
exit mouseup
or
exit to top
:D


Best

Klaus

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 7:33 pm
by keram
Thanks,
I was overzealous to really exit :)

Re: hide a field when clicking/tapping outside of it

Posted: Tue May 06, 2014 7:39 pm
by Klaus
keram wrote:Thanks,
I was overzealous to really exit :)
:D :D :D