Page 1 of 1

Stuck on a right click

Posted: Sat Jul 11, 2009 11:42 am
by Damlimey
First of all, my thanks to jansschenkel and shadowslash for their help with this but I've come unstuck. Here's an example of how I've tried to set up a player start/stop button with a right click menu option, maybe someone can tell me where I've gone wrong...

Code: Select all

start/stop button code:
on mouseUp
   if pMouseButton is 1 then  -- left-button click
     do your normal thing
  else
   popup button "rightclick"
 end if
   if the filename of player "p1" is "" then exit mouseUp
   put the label of me into myLabel 
 if myLabel is not "STOP" then 
    set the label of me to "STOP"
    start player "p1" 
   else 
   set the label of me to "START" 
   stop player "p1" 
   # this resets the player to the beginning 
   set the currenttime of player "p1" to 0 
end if

end mouseUp
And here is the right click pop up menu code:

Code: Select all

on menuPick pMenuItem
  answer pMenuItem
end menuPick 
Thank you in advance,
geoff

Posted: Sat Jul 11, 2009 12:48 pm
by malte
Hi,

you do not pass the parameter in mouseUp

should read

on mouseUp pMouseButton

Hth,

Malte

Thank you Malte

Posted: Sun Jul 12, 2009 10:24 am
by Damlimey
I have found another approach which is shown here...

Code: Select all

on mouseUp mouseButtonNumber 
 if mouseButtonNumber = 1 then do leftclickstuff 
 if mouseButtonNumber = 3 then do rightclickstuff 
end mouseUp
This looks like a more elegant way to proceed but I do have another question...

Now that I have a pop up menu on my right-click, I am finding it hard to find out how to use the menu items command. If for example I want to have a 'load' option in the menu item list, how do I write the command line to action that menu item?

Thank in advance,
D

Posted: Sun Jul 12, 2009 10:37 am
by Klaus
Hi D,

let me first say that context menus that appear on right/control click are supposed to appear "on mousedown". This is at least my observation.

Sou you should script this:

Code: Select all

## Only hanlde right clicks!
on mousedown tButton
  if tButton = 3 then
    popup btn "my context menu" at the mouseloc
  end if
end mousedown

## Handle "normal" clicks with the left mousebutton
on mouseup tButton
  if tButton <> 1 then
    exit mouseup
  end if
  ## do your mouseup stuff here..
end mouseup
To handle the choosen menutitems from the popup you need to do it in the
"menupick" handler of the popup button like this:

Code: Select all

on menupick tItem
  switch tItem
    case "Load"
       ### do your "load" stuff
    break
   case "Another choosen menu item"
     ### do other stuff etc...
   break
   case "Yet another choosen menu item"
     ### do other stuff etc...
   break
  end switch
end menupick
Hope that helps.


Best

Klaus

Thank you Klaus

Posted: Sun Jul 12, 2009 9:18 pm
by Damlimey
Once again, you've cleared my confusion as well as putting me on the right path!

That all works really well.

D

Posted: Mon Jul 13, 2009 12:05 pm
by shadowslash
Klaus wrote:

Code: Select all

on mousedown tButton
  if tButton = 3 then
    popup btn "my context menu" at the mouseloc
  end if
end mousedown
Lollllllllllllll this was one of the RunRev mysteries that I can't seem to find an answer of and that I'm too shy to ask about... Thanks a lot! Image

Posted: Mon Jul 13, 2009 12:45 pm
by !Jerry!
shadowslash wrote:
Klaus wrote:

Code: Select all

on mousedown tButton
  if tButton = 3 then
    popup btn "my context menu" at the mouseloc
  end if
end mousedown
Lollllllllllllll this was one of the RunRev mysteries that I can't seem to find an answer of and that I'm too shy to ask about... Thanks a lot! Image
Hi shadowslash!

These mysteries are old enough :-):

Posted: Thu Apr 27, 2006 5:11 pm Post subject: Re: pop-up menu on mouse right button click
Janschenkel wrote:A better option is to put your opup menu button somewhere off-screen, and then use a script like:

Code: Select all

on mouseUp pMouseButton
  if pMouseButton = 3 then 
    popup button "MyPopupButton" at the clickLoc
  else
    -- do other stuff here
  end if
end mouseUp
The popup menu button will receive the 'menuPick' message when the user picks one of the items, so you'll have to move some of your logic into that menu button as well:

Code: Select all

on menuPick pItem
  switch pItem
    case "Hello world"
      answer "Hello, world!"
      break
    case "Foo"
      answer "Bar" with "Cancel"
      break
    -- more case statements here
  end switch
end menuPick
Hope this helped,

Jan Schenkel.
Jerry

Posted: Mon Jul 13, 2009 12:47 pm
by shadowslash
Yah well, I just started Revving last month Image and I kinda missed that topic... Image

Posted: Mon Jul 13, 2009 12:59 pm
by !Jerry!
Don't cry! It is too late! This is a good lesson for the next time!

:lol: :lol:
Jerry

Posted: Mon Jul 13, 2009 1:03 pm
by shadowslash
!Jerry! wrote:Don't cry! It is too late! This is a good lesson for the next time!

:lol: :lol:
Jerry
Lol ofcourse...
-------
Follow me now on Twitter -> http://Twitter.com/shadowslash
Image