3 questions from a newbie
Robert Brenstein
rjb at robelko.com
Thu Mar 31 11:03:45 EST 2005
At 17:07 +0200 31.03.2005, Rob Meijer wrote:
>I am in my second trial period, still trying to
>complete a application.
>For this time I cannot find a solution for:
>
>1.
>how to import an icon from elswhere?
>I cannot find the good one in the build-in iconlist
Import image or copy-paste should do. An icon is just an image of certain size.
>2.
>In a listbox-field I want the selectedt line be hilited permanently
>until a next line is clicked. Now the the line is hilited for the
>tihe mouse is pressed down.
Make it a list field (lock it and set the autohilite to true).
However, I suspect that you aleady have that and the hilite
disappears on mouseUp because of something in the script. You may set
the hilitedLines to restore the selection at the end of the handler
(cf script below).
>3.
>In the same listboxfield I want to choose a line just by pressing down
>a key: f.i. the R to get the first line beginning with a R.
>The only way to choose now is with mouse or arrow-keys.
place the following handler on the card (untested but fully commented):
on keyDown theKey
set the cursor to watch
-- transfer fld content to var
get fld "listbox"
-- preserve current selection
put the hilited lines of fld "listbox" into h
-- preset line counter
put 1 into s
-- loop through lines
repeat for each line t in it
-- increase counter (we are purposefully 1 off)
add 1 to s
-- escape if condition met
if char 1 of t is theKey then exit repeat
end repeat
-- check if we found a match
if s > the number of lines of it then
-- no match so restore earlier selection
put h into s
-- tell user that no match found
beep
else
-- correct line reference
substract 1 from s
end if
-- update display if a line is selected
if s is not empty then
-- set the hilite
set the hilitedLines of fld "listbox" to s
-- scroll the field accordingly (12 is line height)
set the scroll if fld "listbox" to (s-1)*12
end if
end keyDown
Robert Brenstein
More information about the use-livecode
mailing list