Click doesn't register after code selects a line in a list field

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
MichaelBluejay
Posts: 230
Joined: Thu Jul 01, 2010 11:50 am

Click doesn't register after code selects a line in a list field

Post by MichaelBluejay » Sat Feb 15, 2025 9:40 am

I have a text input field and a couple of list fields.

When I edit the value of the input field, it puts that value into the first list field and selects the line, e.g.:

Code: Select all

on closeField
   updateTitle
   pass closeField -- Thought this might help, but it doesn't.
end closeField

on updateTitle
  put me into line 4 of fld listField1
  select line 4 of fld listField1
end updateTitle
If I edit the input field and then click on a line on the 2nd list field, nothing happens: The clicked line doesn't hilite, and the mouseup doesn't fire. If I click on the same line on the 2nd list field again, it works.

Any idea how I can get the click to work the first time?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Click doesn't register after code selects a line in a list field

Post by bn » Sat Feb 15, 2025 11:44 am

Hi Michael,

Your current code in the input field takes the focus away from the second list field because of the

Code: Select all

select line 4 of fld listField1
You can avoid setting the focus to listField1 with this code that does not take focus away from the second listfield when clicking on a line in it

Code: Select all

on closeField
   updateTitle
end closeField

on updateTitle
   put me into line 4 of fld listField1
   --select line 4 of fld listField1
   set the hilitedLine of field listField1 to 4
end updateTitle
I find it a bit unusual to do data entry using "closeField". I would do the data entry on for example using

Code: Select all

on returnInField
   updateTitle
end returnInField

on enterInfield
   returnInField
end enterInfield
That way data entry is done and does not interfere with focus etc.
And the user sees right away what has changed (typos included) and not after the user has done anything that triggers "closeField".
Unless of course you have a special reason to use "closeField" as trigger.

Kind regards
Bernd

MichaelBluejay
Posts: 230
Joined: Thu Jul 01, 2010 11:50 am

Re: Click doesn't register after code selects a line in a list field

Post by MichaelBluejay » Sat Feb 15, 2025 1:26 pm

Thank you, Bernd, changing the code from "select line..." to "set the hilitedline..." fixed it.

I'm using closeField because I don't want to make the user press the Return or Enter key. I want the changes populated into my list field as soon as the user clicks away onto something else. Is closeField not the right way to do that? I'm also handling returnInField and enterInField, but if that's *all* I handled, it seems like the changes wouldn't get populated into my list field.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Click doesn't register after code selects a line in a list field

Post by bn » Sat Feb 15, 2025 1:57 pm

MichaelBluejay wrote:
Sat Feb 15, 2025 1:26 pm
I'm using closeField because I don't want to make the user press the Return or Enter key. I want the changes populated into my list field as soon as the user clicks away onto something else. Is closeField not the right way to do that? I'm also handling returnInField and enterInField, but if that's *all* I handled, it seems like the changes wouldn't get populated into my list field.
That comes down to what user interface you have in mind. I think the users are used to apply changes/data entry/searches by using return/enter. Or clicking on a dedicated button.

"CloseField" can be confusing when you imagine the following:
During data entry I am not sure about spelling and see the the word is somewhere on the page, I decide to copy the word from there but my attempt at the entry which is still in the entry field gets applied. Not what I would expect.

In my testing return/enter work as expected without a "closeField" handler with the code I posted above.

It is just an interface question, you decide.

Kind regards
Bernd

Post Reply