Moving text from scrolling list to another 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
westerw
Posts: 14
Joined: Tue Apr 09, 2013 7:33 pm

Moving text from scrolling list to another field

Post by westerw » Wed Jun 12, 2013 9:57 pm

I have a scrolling field with entries and have been reading the dictionary, but cannot seem to solve this simple task.
I am trying to move the line clicked on by the user into a field (txtTitle).

The dictionary for "clickLine" says:

If the field is locked, the clickLine function is most useful within a handler (such as mouseDown or mouseUp) that is triggered by the mouse click.

If the field is unlocked, mouseDown and mouseUp messages are not sent when the user clicks in the field (unless the user right-clicks or holds down the Control key while clicking). Use the clickLine function within a selectionChanged handler to determine what line the user is editing in an unlocked field.


Here is my "mouseUp" code
on mouseUp
set the lock of field "lbxTitle" to true
put the value of the clickLine into theLine
set the text of field "txtTitle" to theLine
set the lock of field "lbxTitle" to false
end mouseUp


When I comment out the last line and check the properties for "lbxTitle" after the mouseUp, the Lock Text box is not checked (not locked).
If I use the Ctrl key + mouse click over a line in the scrolling field, the LINE moves into the "txtTitle". This matches the dictionary for an "unlocked" field.

Thanks for the help
bill

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

Re: Moving text from scrolling list to another field

Post by bn » Wed Jun 12, 2013 10:56 pm

Hi Bill,

the field must be locked before it can get a mouseUp event. So it seems that your field "lbxTitle" is not locked. There is no use in setting "the lockText" (not lock as you wrote) of the field in the mouseUp handler.

Either you right click/control click then the field will get the mouseUp handler even if unlocked, or the field has to be locked before = the lockText of the field is set to true before then there is not use to set it in mouseUp the handler.

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Moving text from scrolling list to another field

Post by dunbarx » Wed Jun 12, 2013 11:30 pm

Hi.

What Bernd said.

You have the basics down pretty well: You might, however, if the field is locked, simply:

Code: Select all

on mouseup
   put the value of the clickLine into fld "txtTitle"
end mouseup
It is important to decide whether a field should be locked or not, and it generally stays put. The following is a kluge, and probably will cause more problems than it solves, but it allows the field to be unlocked and still receive mouseUp messages:

Code: Select all

on mouseEnter
   set the locktext of  me to "true"
end mouseEnter

on mouseup
   put the value of the clickLine into fld "txtTitle"
end mouseup

on mouseLeave
   set the locktext of  me to "false"
end mouseLeave
Now this is really doing it the hard way. But at least you see how it works.

If the field is unlocked, what about:

Code: Select all

on openfield
      put the value of the clickLine intofld "txtTitle"
end openfield
Now this is not terribly robust. In fact, it is awful. Do you see why? If you play around for a while, you should. This playing thing is important, by the way. Write back with your progress.

Craig Newman

Post Reply