Change the Group of a MaxGUI Gadget?

BlitzMax Forums/BlitzMax Programming/Change the Group of a MaxGUI Gadget?

Gabriel(Posted 2006) [#1]
I can set the group when I create it. I can retrieve the group by using GadgetGroup, but there does not appear to be a SetGadgetGroup command. Is there a way to do it, or not?


WendellM(Posted 2006) [#2]
Not that I know of (though I'm no expert). Perhaps you could work around that by deleting/recreating gadgets to reassign groups (you've probably already considered that <g>)?


Gabriel(Posted 2006) [#3]
Yeah, unfortunately the only reason I want to change the group is to work around my program crashing when I delete the gadget. I figured if I could remove it from it's parent gadget, I can delete all other gadgets apart from this one until there's a bugfix for canvases being freed.

Ah well, no matter. I guess I can just not free anything for now.


Jake L.(Posted 2006) [#4]
Wasn't there a workaround to first call SetGraphics (CanvasGraphics()) before freeing it?


Gabriel(Posted 2006) [#5]
Yes, but that clashes with the other renderer. Dunno why. It shouldn't really.


tonyg(Posted 2006) [#6]
Does this do it?
SuperStrict

Local MyWindow:TGadget = CreateWindow("Canvas Example" , 200 , 200 , 320 , 240)
Local mywindow2:TGadget = CreateWindow("Dummy window" , 400,400,200,200)
Local MyCanvas:TGadget=CreateCanvas(10,10,290,140,MyWindow)

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (MyCanvas)
    DrawRect  20,20,50,80
	 Flip
 Case EVENT_MOUSEDOWN
			Print "fIRED"
	 		mycanvas._setparent(mywindow2)
 End Select
 Local current_group:TGadget = GadgetGroup(mycanvas)
 DebugLog gadgettext(current_group)
Forever


There is also a driver.setgroup method but it's commented out.
<edit> To use gadgettext.


Gabriel(Posted 2006) [#7]
That works for me. Thanks Tony!


Mark Tiffany(Posted 2006) [#8]
mycanvas._setparent(mywindow2)

This tweak should be converted to a new maxgui function (SetGadgetGroup) and posted in the Module Tweaks forum. Skid & mark could then make it an official addition (which is much more likely when it works cross-platform).


Dreamora(Posted 2006) [#9]
There is a reason why it isn't

setparent is used in combinatin with other functions and if you use it on gadgets without calling the rest, you risk that relationships break and your whole app makes baba boom.
there is a thread where skid commented on that with more or less that answer when I remember correctly.


tonyg(Posted 2006) [#10]
If you could find it, that would be good.
I did see this where Skid didn't make much comment and, from that, suggests it can be used.
I did also notice this where the same issue was raised before.
I think it should have it's own function and the request made to BRL. However, I'm tired of requesting things only to be ignored.


Dreamora(Posted 2006) [#11]
The GUI is still far away from the point of beeing really usable compared to Blitz Plus or anything ... but it is at least a base to build on. *Although I still hope that this base gets some additions like EventHandles on the Gadgets directly*


tonyg(Posted 2006) [#12]
If you could find that thread it'd be appreciated.