Jump to content

[SOLVED] GUI evolution?


photo

Recommended Posts

Posted

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?

  • 2 weeks later...
Posted

Hi Sergey,

 

Sorry for the late reply.

  1. 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();
    	}
    }
  2. 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>
    
  3. 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:

Posted

but how get item in treebox by this way,? calc?

Posted

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:

×
×
  • Create New...