steve3d Posted September 21, 2011 Share Posted September 21, 2011 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? Link to comment
manguste Posted September 23, 2011 Share Posted September 23, 2011 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(). Link to comment
danni.coy Posted September 24, 2011 Share Posted September 24, 2011 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"); } } Link to comment
steve3d Posted September 26, 2011 Author Share Posted September 26, 2011 tested, using GUI_CLICKED on a button, it will only fires callback on left click, all other mouse-button won't fire the callback. Link to comment
manguste Posted September 27, 2011 Share Posted September 27, 2011 It turned out you are right, only left click is detected :( As a workaround, in the update function you can manually check the following conditions: * whether a widget is in focus (isFocused()) * if RMB is clicked (engine.app.clearMouseButtonState(APP_BUTTON_RIGHT) to handle it once or engine.app.getMouseButtonState(APP_BUTTON_RIGHT)) Link to comment
steve3d Posted September 27, 2011 Author Share Posted September 27, 2011 Will this feature be added to next update? Link to comment
manguste Posted September 28, 2011 Share Posted September 28, 2011 Sorry, the development schedule for the nearest future is way too tight. You can use a suggested workaround though. Link to comment
Recommended Posts