sergey.pozhidaev Posted December 6, 2013 Share Posted December 6, 2013 2 questions: 1. i need right click event on treebox widget item. what i need to do? 2. how fill Widgets setData field from UI files? 3 bonus: how control engine.visualizer.renderEllipse segments count? Link to comment
silent Posted December 20, 2013 Share Posted December 20, 2013 Hi Sergey, Sorry for the late reply. You can check for mouse position in update() and check if mouse button 2 is pressed: int mouse_x = gui.getMouseX() - widget.getPositionX(); int mouse_y = gui.getMouseY() - widget.getPositionY(); if(mouse_x > 0 && mouse_x < widget.getWidth() && mouse_y > 0 && mouse_y < widget.getHeight()) { if(engine.app.clearMouseButtonState(APP_BUTTON_RIGHT) == true) { right_clicked_callback(); } } You can create new parameter <data> inside the *.ui-files. After that you can get acces to it via getData() function. For example: <?xml version="1.0" encoding="utf-8"?> <ui version="1.00"> <icon name="my_icon" export="1"> <tooltip>my icon</tooltip> <callback type="clicked">icon_clicked</callback> <data>my data</data> </icon> </ui> I'm afraid there is no way to control segments count, sorry. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
sergey.pozhidaev Posted December 20, 2013 Author Share Posted December 20, 2013 but how get item in treebox by this way,? calc? Link to comment
silent Posted December 20, 2013 Share Posted December 20, 2013 Hi Sergey, Yes, you can calculate current highlighted item based on current mouse position and item height. Here is a basic example, where calculation based only on item's font size: int step = widget.getFontSize(); int item = mouse_y / step; forloop(int i = 0; widget.getNumItems()) { if(i == item) { widget.setCurrentItem(widget.getItem(item)); break; } } If you are using texture for your items you will need to get it's height instead of font size. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts