Toggling hilite of list field line

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
stam
Posts: 3073
Joined: Sun Jun 04, 2006 9:39 pm

Toggling hilite of list field line

Post by stam » Sun Mar 07, 2021 3:40 pm

Hi all,
sorry for the basic question, but i can't figure this one out :-/

I've set the "click to toggle" of a list field to true -- great, i can click to toggle the hilite and put the list field into a state where no lines are hilited.

However, what I'm looking for is a way to do this in script - is this possible?
apparently it's not possible to set the hilite of the selectedLine...

many thanks
Stam

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Toggling hilite of list field line

Post by Klaus » Sun Mar 07, 2021 3:50 pm

Hi Stam,

not sure, what exactly are you after?
But it surely will be scriptable!

Hint:
If you did not already, in LC preferences -> General
check -> Property labels are -> Name of Livecode property
Then you see the names of all properties in the inspector that you can use in scripts
and not just the description of that property.

Best

Klaus

stam
Posts: 3073
Joined: Sun Jun 04, 2006 9:39 pm

Re: Toggling hilite of list field line

Post by stam » Sun Mar 07, 2021 3:57 pm

Klaus wrote:
Sun Mar 07, 2021 3:50 pm
not sure, what exactly are you after?
But it surely will be scriptable!
Hi Klaus

I'd like to put a listField in a state where no lines are hilited - this is not the default state and unless you set 'click to toggle' it's not possible not to hilite some line or other.

The scenario where this is used is a listField with many options and a separate searchField; when the user types in the searchField it should find and select a line in the listField - however when no matches found, it should select none.

It's that last bit I can't figure out, hope that makes sense....

A simple example: A listField called "texts" and a search field called "search". A button with this script

Code: Select all

on mouseUp pButtonNumber
   doFind the text of field "search"
end mouseUp


command doFind pText
   find string pText in field "texts"
   if the foundLine is not empty then 
      select the foundLine
   else
      //code to deselect the hilitedLine so no lines hilited
   end if
end doFind
but can't find what i should put in the 'else' statement that would deselect the previously selected line

stam
Posts: 3073
Joined: Sun Jun 04, 2006 9:39 pm

Re: Toggling hilite of list field line

Post by stam » Sun Mar 07, 2021 4:08 pm

I should also say i've tried examining all the properties of the list field as i often find things may not be obvious in the inspector panel. I ran this in the multiline messagebox:

Code: Select all

put the properties of field "texts" into myArray
combine myArray using return and ": "
put myArray
This shows a detailed listing of all the properties, but still couldn't see what i could use...

Grateful for any help!
Stam

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Toggling hilite of list field line

Post by Klaus » Sun Mar 07, 2021 4:09 pm

AHA! :-)

Code: Select all

...
set the hilitedlines of fld "your listfield here" to EMPTY
...

stam
Posts: 3073
Joined: Sun Jun 04, 2006 9:39 pm

Re: Toggling hilite of list field line

Post by stam » Sun Mar 07, 2021 4:10 pm

Perfect, thank you!!!
I was sure I tried that, but but have done something silly as this now works!

Post Reply