Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 12:05 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Feb 12, 2012 11:20 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Can you point me in the right direction? Left click is working dandy for radial buttons/run able, but would like to be able to right click to close menu. I can close the menu fine, but not sure how to detect a right click and if it's over the radial menu.


Top
 Profile  
 
PostPosted: Mon Feb 13, 2012 6:57 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1188
How do you create the popup menu?

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Mon Feb 13, 2012 6:08 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Code:
   RadialPopupMenu rpm = new RadialPopupMenu(this);
         rpm.addButton("build_t1", new Runnable() {
            public void run() {
               // do stuff
            }
         });

      rpm.setSize(size, size);
      rpm.setTheme("radialpopupmenu");
      rpm.openPopup();

      rpm.setPosition((size / 2), (size / 2));

      add(rpm);


Top
 Profile  
 
PostPosted: Mon Feb 13, 2012 6:42 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1188
Wait - that shouldn't work at all. You can't add a PopupWindow subclass to another widget, and you need to check the return value of openPopup() to see if it really did open.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Mon Feb 13, 2012 10:42 pm 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
Yes, that is true. I have a widget that adds the RPM. It does work with some tinkering. The reason I did this is so I can have a "background" widget to the RPM. Right now it's just a background image, but eventually I'd like to also add tooltips or text or other components too. I think it looks neat, I can show you a screenshot if you want.

I'll start checking the status of openPopup.

Is there any way to detect a right click on Widet or RPM? I want an easy way to exit out of it. I don't see an addCallback to either.


Top
 Profile  
 
PostPosted: Tue Feb 14, 2012 12:52 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1188
A PopupWindow (RadialPopupMenu is a subclass of that) is not designed to be added as a child window - so it won't behave correctly.
The only reason that you can add it is that a run time check would be a bit expensive.

To handle inputs events for a popup you can override handleEventPopup().

The RPM is designed to be opened from a mouse click which then transfers the (potential) drag gesture to the RPM which allows to do single stroke menus. It should close as soon as you release the mouse button. You can try the GameUIDemo.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group