Lots of Editing

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
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Lots of Editing

Post by RossG » Wed May 11, 2016 12:30 pm

I'm not clever enough to write common code for a lot
of buttons (but will get to it eventually).

Is there some way of opening half a dozen or so "on mouseUp"
other than the "four-click" method i.e.

Click on group
Click on "Edit Group"
Click on the button.
Click on Editor button.

I know (and use) the fact that once opened in the
Editor they're available on the drop-down but getting
them there is the rub.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Lots of Editing

Post by Dixie » Wed May 11, 2016 1:00 pm

'm not clever enough to write common code for a lot of buttons
Oh Yes you are !... :-) You need to get into the habit of using behaviors... I have attached a simple stack example...

There are 5 buttons on the card
Buttons 1 through to 4 would have common code, so that you don't have to keep repeating the script in each button we can use a 'behavior button' to control them...

Easy to set up... look in the stack script..
Easy to control and make changes and additions... look in the script of the button 'buttonbehavior'
Attachments
Untitled 1.livecode.zip
(1.13 KiB) Downloaded 255 times

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

Re: Lots of Editing

Post by dunbarx » Wed May 11, 2016 1:30 pm

Hi.

What Dixie said.

And you are probably well past the ability to place a single "mouseUp" handler in the group script, something like:

Code: Select all

on mouseUp
  answer the name of the target
  doStuffJustForThatSpecificButtonSinceYouAlreadyKnowWhichOneYouClicked
end mouseUp
Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Lots of Editing

Post by jacque » Wed May 11, 2016 5:11 pm

As mentioned, behaviors are the best way to handle shared scripts. But for future reference, the fastest way to get to an object script is:

Make sure the "Select grouped controls" icon in the toolbar is bolded.
Hold down option-command and click on the object.

Another way is to select the object with the edit tool and click the script icon in the toolbar.

A third way is to hold down option-command-shift, right click the object, and choose to edit the script from the contextual menu.

If you are on Windows, substitute the alt key for "option" and the control key for "command" in the above.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Lots of Editing

Post by RossG » Thu May 12, 2016 12:55 pm

This is my answer to my query.

Open stack.
Open Project Browser.
If necessary expand group to find the button.
Click once on graphic at right which shows the number of lines of code.
Code opens in Editor.

Open as many bits of code as you want.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Lots of Editing

Post by RossG » Tue May 17, 2016 1:50 pm

Not only but also...

If I clone a number of buttons can I change the
on mouseUp code to suit e.g. if the original
button is Button1

on mouseUp
put field Zero1 into field Numbers1
end mouseUp

The the first clone (Button2) would need

on mouseUp
put field Zero2 into field Numbers2
end mouseUp

Since nothing is impossible with LC (so far)
it's just a matter of knowing the right words.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

cubist
Posts: 5
Joined: Tue May 17, 2016 1:42 pm

Re: Lots of Editing

Post by cubist » Tue May 17, 2016 2:16 pm

RossG wrote:Not only but also...

If I clone a number of buttons can I change the
on mouseUp code to suit e.g. if the original
button is Button1

on mouseUp
put field Zero1 into field Numbers1
end mouseUp

The the first clone (Button2) would need

on mouseUp
put field Zero2 into field Numbers2
end mouseUp

Since nothing is impossible with LC (so far)
it's just a matter of knowing the right words.
You could give each button a custom property called, say, MyFields. With this code as a behavior…

Code: Select all

on mouseUp
   put field (item 1 of the MyFields of me) into field (item 2 of the MyFields of me)
end mouseUp
…putting the appropriate values into each button's MyFields property should do the trick.

Post Reply