Jump to content

is it possible to add a right_clicked callback on widgets?


photo

Recommended Posts

Posted

now widgets support almost all kind of callbacks. but sometime I need a callback of right-clicked on some widgets, is it possible to add this kind of callback?

Posted

GUI_CLICKED callback is for all buttons of the mouse: left, right and middle one. After it was returned, you can check what button of the mouse was pressed via getMouseButton().

Posted

are you sure... My current test case only gives a GUI_CLICKED event on a left mouse button.

and neither engine.app.getMouseButton() engine.gui.getMouseButton() detects any mouse button down() - (which kind of makes sense since GUI_CLICKED seems to triggered on mouse up).

 

callback is set via (WidgetSprite).

map_widget.setCallback(GUI_CLICKED,"MapWindow::on_click",this);

callback is implemented

void on_click(MapWindow w) {w.clicked();}
void clicked() {
 	log.message("clicked\n");
 if(engine.gui.getMouseButton()==APP_BUTTON_LEFT) {
     	log.message("left\n");
   	} else if (engine.gui.getMouseButton()==APP_BUTTON_RIGHT) {
     	log.message("right\n");
   	}
}

Posted

tested, using GUI_CLICKED on a button, it will only fires callback on left click, all other mouse-button won't fire the callback.

Posted

Sorry, the development schedule for the nearest future is way too tight. You can use a suggested workaround though.

×
×
  • Create New...