SOLVED on FocusIn not working

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

SOLVED on FocusIn not working

Post by Da_Elf » Sat Dec 30, 2017 12:36 am

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
Last edited by Da_Elf on Sat Dec 30, 2017 6:27 pm, edited 2 times in total.

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: on FocusIn not working

Post by quailcreek » Sat Dec 30, 2017 12:49 am

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.
Tom
MacBook Pro OS Mojave 10.14

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: on FocusIn not working

Post by Da_Elf » Sat Dec 30, 2017 12:54 am

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

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: on FocusIn not working

Post by Da_Elf » Sat Dec 30, 2017 12:59 am

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

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: on FocusIn not working

Post by Klaus » Sat Dec 30, 2017 12:59 am

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: SOLVED on FocusIn not working

Post by dunbarx » Sat Dec 30, 2017 1:06 am

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

quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm
Location: McKenna, WA

Re: SOLVED on FocusIn not working

Post by quailcreek » Sat Dec 30, 2017 1:07 am

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
Tom
MacBook Pro OS Mojave 10.14

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: SOLVED on FocusIn not working

Post by dunbarx » Sat Dec 30, 2017 1:36 am

Type putting this in the fld.
MouseUp is not sent in an unlocked field.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SOLVED on FocusIn not working

Post by jacque » Sat Dec 30, 2017 5:37 pm

See if selectionChanged does what you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: SOLVED on FocusIn not working

Post by dunbarx » Sat Dec 30, 2017 7:16 pm

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

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: SOLVED on FocusIn not working

Post by Da_Elf » Mon Jan 01, 2018 12:19 am

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  

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: SOLVED on FocusIn not working

Post by jacque » Tue Jan 02, 2018 12:40 am

Try adding an exitField handler:

Code: Select all

on exitField
  closeField
end exitField
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: SOLVED on FocusIn not working

Post by Da_Elf » Tue Jan 02, 2018 2:00 am

whoohoo. it works. They had something about erasing changes to the field so i didnt think it was what i needed.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”