Two Questions About My Search Field

Gregory Lypny gregory.lypny at videotron.ca
Mon Jan 12 17:41:26 EST 2009


	Hello everyone,

	I've created a search field that takes a phrase typed into it and  
searches a data field for lines containing the phrase.  It works in  
the usual way where the search becomes narrower the more you type.   
What I haven't been able to do is go backwards, that is, make the  
search wider as characters are deleted from the end of the search  
string when the delete key is hit.  When the delete key is hit,  
nothing happens, and I'm not sure how to work a delete key message  
into the handler.

on keyDown pKey
    put me & pKey into searchString
    get fld "Data"
    repeat for each line thisLine in it
       if searchString is among the words of thisLine
       then
          put thisLine & return after hits--Whole words
          next repeat
       else
          if thisLine contains searchString then put thisLine & return  
after otherHits
       end if
    end repeat
    put otherHits after hits
    if the last character of hits is return then delete the last  
character of hits
    put hits into fld "Browse List"
    put 1*the number of lines in hits && "records" into fld "Number of  
Records"
    pass keyDown
end keyDown

	My second question concerns the format of the field itself and the  
Geometry Manager.  I jazzed up the field by importing three PNG images  
to make it look like Apple's hot dog shaped search field.  The two  
rounded ends remain fixed in size and maintain their relative  
positions while the middle segment is scaled horizontally if the stack  
is resized.  It all works wonderfully (I believe Eric Chatonet gave me  
this tip ages ago --- thanks, Eric) except that whenever the stack is  
reopened the middle segment is displayed in its original size  
regardless of the size of the stack at the time it was closed.  This  
means the hot dog appears sliced until the user resizes the stack, at  
which time the pieces will snap back together.  Any fix for this  
little glitch?

	Regards,

	Gregory



More information about the use-livecode mailing list