Right Click starter

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

Right Click starter

Post by Damlimey » Fri Jul 03, 2009 4:17 pm

Hello all,

In my project, I have a button that I would like to offer 'right click' options for, ie; Load a file, clear a file, etc...

Where can I find a tutorial on this and does anyone have any advise or tips for this very inexperienced traveler in Runtime?

Thanks in advance,

D

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Sat Jul 04, 2009 5:45 am

You might want to consider using popup buttons. You can do so by dragging the PopUp Menu control from the tools palette to your stack.
Image
Parañaque, Philippines
Image
Image

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sat Jul 04, 2009 6:44 am

If you wqant your button to work for both left- and right-button clicks, doing some action for the left-button, and displaying the menu when right-clicking, then the following method will work best.
Put a popup-menu next to your button, name it "ContextualMenu" and set its menu content using the Inspector palette; set its script to

Code: Select all

on menuPick pMenuItem
  answer pMenuItem
end menuPick
and finally hide it. Then set the script of your button to

Code: Select all

on mouseUp pMouseButton
  if pMouseButton is 1 then  -- left-button click
    ... do your normal thing ...
  else
    popup button "ContextualMenu"
  end if
end mouseUp
Now, when you left-click on the button, it continues to work as normal; when you right-click, the contextual menu pops up - and when you choose one of its items, the script simply tells you which item you picked.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

Oh yeah!!!

Post by Damlimey » Sun Jul 05, 2009 8:50 am

Far out guys! Thanks for that, it's working a treat so, while I have your attention...

I've succesfully managed to load a music file into a button, I can play it and puase it with that button, I can make options available by a right click menu now thanks to you guys but... How do I empty the button before I put a new file in it? ie, I just want an empty button.

Yours truly,

D
So, it's a big Salami... Just take it one slice at a time.

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Sun Jul 05, 2009 8:54 am

Hi damlimey,

When you say succesfully managed to load a music file into a button, what do you mean? Did you put it in a custom property? What exactly do you want to achieve when you say I just want an empty button how empty? As in without any menus? As in without any text? Please specify. Image
Parañaque, Philippines
Image
Image

Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

Hi Shadowslash...

Post by Damlimey » Sun Jul 05, 2009 9:15 am

I'm building an audio player and as I'm on a massive learning curve here, I've built several basic stacks and I use each stack to work out and test one or two simple functions at a time.

The plan is to have a button which I can load with a music file and then play it when I click the button. However, I want to be able to "purge" the player so that it is empty. I can then add a different file if required.

I use a load button to load the player, a play/pause button to... Well play & pause but I would like to offer the "load .wav" and "remove.wav" options as part of the right click menu.

However, I'm finding it hard to track down any examples of a simple "on mouse down" type of code to simply clear the current file from the player.

Sorry to go on and on but does this help?

D
So, it's a big Salami... Just take it one slice at a time.

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

Post by Klaus » Sun Jul 05, 2009 11:56 am

Hi D,

we need more info, since we do not know how you are doing what you are doing.

Are you setting the filename of player with "load a music file into a button"?
If yes, then the magic line is:
...
set the filename of player "XYZ" to empty
...

If not, well, see line 1 :-)


Best

Klaus

Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

That does it...

Post by Damlimey » Sun Jul 05, 2009 1:21 pm

Hi Guys,

Yes, that does the trick, that's all I needed to know at this stage. Now I can load and unload a music file from the player. Next step is to put the unload option into the right click menu and I can move onto the next mystery.

The device I'm trying to create is essentially for sound engineers like me, who have to fire sound effects and music stings into a production on very short notice. The idea is to have a page with say 20 "players" on it, each loaded with various music files ready to go at the click of a mouse.

Some files may be changed during the event hence a right click function menu to remove/reload files.

I don't want to use propriatory dedicated devices costing thousands os euros though, I want to use a simple bit of PC software.

Regards,
D
So, it's a big Salami... Just take it one slice at a time.

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Tue Jul 07, 2009 6:39 am

Well it's a good thing that you settled for RunRev. A lot of people seem to think that Rev is complicated but it's not. I myself thought of that before but when I spent a couple of days with Rev and checking the sample stacks and of course, getting some help from forum users, I managed to get around my problems... Image Just take a look at this story of a guy who got locked out and saw the real ease of Rev. http://forums.runrev.com/phpBB2/viewtopic.php?t=3223 Image
Parañaque, Philippines
Image
Image

Post Reply