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 »

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

Re: on FocusIn not working

Post 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.
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 »

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 »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: on FocusIn not working

Post 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.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: SOLVED on FocusIn not working

Post 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
quailcreek
Posts: 746
Joined: Sun Feb 04, 2007 11:01 pm

Re: SOLVED on FocusIn not working

Post 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
Tom
MacBook Pro OS Mojave 10.14
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: SOLVED on FocusIn not working

Post by dunbarx »

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: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SOLVED on FocusIn not working

Post by jacque »

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: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: SOLVED on FocusIn not working

Post 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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: SOLVED on FocusIn not working

Post 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  
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SOLVED on FocusIn not working

Post by jacque »

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 »

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