Simon.Anderson Posted May 19, 2015 Posted May 19, 2015 Hi, I'm trying to highlight the background of my WidgetComboBox (when it gets clicked on) by creating a Widgetsprite and adding it the parent widget using GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND. I then assign the sprite widget callback GUI_CLICKED to my own callback to draw the highlighting when the sprite is clicked. It works fine and highlights ok, the problem is as soon as I assign a callback to the sprite using sprite.setCallback(GUI_CLICKED... then the combobox stops picking up clicks and never updates. The fact that I assign my own GUI_CLICKED callback to the sprite seems to be the culprit but I'm not sure why? Any ideas/suggestions would be welcome. Thanks, Simon
silent Posted May 19, 2015 Posted May 19, 2015 Hi Simon, Could you please provide a simple test scene? This surely will help to find the root cause much faster. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Simon.Anderson Posted May 19, 2015 Author Posted May 19, 2015 Unfortunately there's a lot of code in our code base and it's all quite complex and interconnected. Very time consuming to pull out into a sample scene :(
Simon.Anderson Posted May 19, 2015 Author Posted May 19, 2015 Ok, so the following code snippet says it best (it works fine): WidgetSprite sprite = new WidgetSprite(gui,"core/editor/gui/color_white.png"); m_hBox.addChild( sprite, GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND ); // // While the following code below is commented out, the checkbox can be checked and receives mouse clicks // //sprite.setCallback(GUI_CLICKED, "OnRowClickedCB", this, m_rowSprites.size(), GUI_CLICKED); // // The following code adds a checkbox over the top of the sprite - it works fine while the previous code is commented out // WidgetCheckBox checkbox = new WidgetCheckBox(engine.getGui(), ""); m_hBox.addChild(checkbox); And the following code doesn't work: WidgetSprite sprite = new WidgetSprite(gui,"core/editor/gui/color_white.png");m_hBox.addChild( sprite, GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND ); //// While the following code below is commented out, the checkbox can be checked and receives mouse clicks//sprite.setCallback(GUI_CLICKED, "OnRowClickedCB", this, m_rowSprites.size(), GUI_CLICKED); //// The following checkbox DOESN'T work - it displays but doesn't receive clicks and never gets checked because the call to "setCallback" above//WidgetCheckBox checkbox = new WidgetCheckBox(engine.getGui(), "");m_hBox.addChild(checkbox); setting the GUI_CLICKED is the reason the clicks don't work. This seems to be the case for all widgets (not just checkboxes). Is there any way around this or is this a bug? Thanks, Simon
maxi Posted May 21, 2015 Posted May 21, 2015 Hi, Simon! I've created a simple scene containing your code. Could you add extra code there to recreate the issue? ww.cpp ww.world
Simon.Anderson Posted May 25, 2015 Author Posted May 25, 2015 Hi there, ok - just paste this init() code into your scene file and you'll see what I mean: int init() { Player player = new PlayerSpectator(); player.setDirection(Vec3(0.755f, -1.0f, 0.25f)); engine.game.setPlayer(player); Gui gui = engine.getGui(); WidgetHBox m_hBox = new WidgetHBox(gui, 0, 0); // Empty string should still load with a red background WidgetSprite sprite = new WidgetSprite(gui, "" ); sprite.setWidth(200); sprite.setHeight(200); m_hBox.addChild(sprite, GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND ); // This causes the checkbox to ignore any mouse clicks sprite.setCallback(GUI_CLICKED, "OnRowClickedCB"); WidgetCheckBox checkbox = new WidgetCheckBox(gui, "combobox"); m_hBox.addChild(checkbox); gui.addChild(m_hBox, GUI_ALIGN_CENTER); return 1;} Basically, All I'm after is a way to change the background colour of my base/bottom containers that contain my widgets that sit on top. This is quite urgent for us - it would be great if you could get back to me asap. Cheers! Simon
maxi Posted May 25, 2015 Posted May 25, 2015 Hi, Simon, yes, its a known issue. You have 2 options: 1) Set checkboxes as GUI_ALIGN_OVERLAP and set their positions manually 2) Don't set callback to sprite, and manually checks for sprite clicked instead: WidgetSprite sprite; /* */ int init() { Player player = new PlayerSpectator(); player.setDirection(Vec3(0.755f, -1.0f, 0.25f)); engine.game.setPlayer(player); Gui gui = engine.getGui(); WidgetHBox m_hBox = new WidgetHBox(gui, 0, 0); sprite = new WidgetSprite(gui, "" ); sprite.setWidth(200); sprite.setHeight(200); m_hBox.addChild(sprite, GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND); WidgetCheckBox checkbox = new WidgetCheckBox(gui, "combobox"); m_hBox.addChild(checkbox); gui.addChild(m_hBox,GUI_ALIGN_CENTER); return 1; } /* */ int update() { //check for sprite clicked int x = engine.gui.getMouseX(); int y = engine.gui.getMouseY(); if(x > sprite.getScreenPositionX() && x < (sprite.getScreenPositionX() + sprite.getWidth()) && y > sprite.getScreenPositionY() && y < (sprite.getScreenPositionY() + sprite.getHeight())) { if(engine.gui.getMouseButton() == APP_BUTTON_LEFT) { //change color ets } } return 1; }
Simon.Anderson Posted May 26, 2015 Author Posted May 26, 2015 Ok thanks - is this fixed in unigine 2.0? And are we any closer to a release?
silent Posted May 27, 2015 Posted May 27, 2015 Hi Simon, Ok thanks - is this fixed in unigine 2.0? This issue is not yet fixed in Unigine 2.0 beta, sorry. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
silent Posted June 25, 2015 Posted June 25, 2015 The bug was fixed. Fix is available with the Unigine 2.0 RC SDK. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts