Closed MangelMaxime closed 8 years ago
How did you add the child specifically?
I used this code :
_panel = new mint.Panel ({
parent: canvas,
name: 'panel1',
x: 10, y: 100, w: 200, h: 200,
options: {
color: new Color().rgb(RefColor.CARROT),
}
});
new mint.Button({
parent: _panel,
name: 'btn_index2',
x: 10, y: 52, w: 60, h: 32,
text: 'Index',
text_size: 14,
options: {
label: { color: new Color().rgb(RefColor.CLOUDS)},
color_hover: new Color().rgb(RefColor.AMETHYST)
},
onclick: function(e,c) { trace('clicked');}
});
https://gist.github.com/Blist/e852d419c734418ff202
Is it a piece of code Who isolate the bug. The panel does not transmit its signals(click, focus, input) to these children. Works with the empty_luxe project.
Just to add a little info, I had a similar problem before with panels being the parent of an interactive element like Buttons and Sliders.
A discussion with @underscorediscovery revealed that the parent element may not be maintaining a list of children properly when the child element is parented and that telling the container/parent element to set the Button/Slider as a child should work (it didn't for me). Here's @underscorediscovery 's words:
- the pattern in mint (for the most part) is to operate on the container (a lot like luxe)
- this is a thing i'll clarify and maybe there's a way around the parent property telling you
- but you should be doing panel.add(slider)
- not slider.parent = panel
- there's usually a lot of annoying code when you have two endpoints that do the same thing, because - - - they'll call each other
- set_parent -> add to parent -> set_parent
- i prefer to keep the workflow clear and stick to "what you operate on" as being consistent
- always do the action / operate on the container
Parenting the interactive element to something other than a panel, like a Window, is the workaround I ended up using.
Thanks @Blist and @ImDeity, the isolated test is exactly all that is needed to fix bugs like this. It's probably something simple.
Ok I had a quick look, and my first guess was close:
var panel = new mint.Panel({
parent:canvas,
name:"panel1",
mouse_input: true,
x:50, y:50, w:200, h:150
});
Note the addition of mouse_input: true
to the constructor for the Panel.
I can't remember off hand if the parent prevents children from receiving events explicitly or not, so I'll still have a closer look at the situation.
In the meantime enable mouse input on the panel and it should work.
I should note though, the default mouse_input is false, specific controls that use the mouse (like windows) set it to true, because they expect mouse events for things like moving and closing and so on. (So the behaviour is somewhat expected to not receive mouse events on a panel, I am looking into if that makes sense for its children)
It looks like this issue would be solved by https://github.com/snowkit/mint/pull/44
Hi, I am not sure if this is a bug or not. But if I add a button inside a panel then the button don't react to mouse input. However, if I place it inside a window then it act correctly.
Is it the intended behavior ?