PDA

View Full Version : Widgets on diecontrols?



joshuha
July 7th, 2007, 04:27
I have been successfull adding textwidgets and bitmapwidgets almost everywhere else but the diecontrol and I really need to do that one the most.

As it is now, the diecontrol sets the icon to whatever icon you use for the default die in the chatwindow.

However, because I use very small diecontrol fields at time I made a set of icons with a big number in the middle to easily tell what kind of die is in the slot. When I try to add a bitmapwidget (or a textwidget with just a number) nothing happens on the diecontrol. I am guessing this is because the graphic for the diecontrol is being drawn on top no matter what but I have tried bringToFront() with no success.



function onInit()
registerMenuItem("D4","d4labeled",3);
if getDice()[1] == nil then
setDice({"d4"});
end
local widget = addBitmapWidget("d4labeled");
widget.setVisible(true);
widget.setPosition("center", 1, 1 );
widget.bringToFront();
end


Using the above I see the icon properly in the menu but the icon on the diefield does not have the bitmap overlaid like I would like (and I have tried with a textWidget with no success either).

Anyone have any ideas besides totally rewriting my own diecontrol type field (which is very ugly)?

Dachannien
July 7th, 2007, 07:58
We've found elsewhere that during onInit, a control doesn't yet have a position and/or size. Is it possible that it also doesn't have a depth yet, either, and so after onInit completes and the control is positioned, it ends up on top of everything else that's been created, including your bitmapwidget?

joshuha
July 7th, 2007, 14:44
Well I have seen several examples of widgets being able to be added fine during the onInit function and I have tested it with other controls like numbercontrols and it works fine. Its just the diecontrol that seems an issue.

-----
I also just tested by putting the code in the onDoubleClick funciton but still not so I think its a matter of the diecontrol not accepting widgets even though it says inheritance is -> windowcontrol -> widgetcontainer.