Author Topic: Creating GuiControl does not come with onWake method?  (Read 351 times)

For some reason, when I create a GuiControl, and dump it, it doesn't come with an onWake method.

Code: [Select]
package SomethingClient
function SomethingGui::onWake(%this)


Code: [Select]
Add-Ons/Client_Something/client.cs (0): Unknown command onWake.

the gui opens, but the commandToServer command doesn't execute
i'm not sure what the problem is here, don't all GUIs come with the onWake command?

The onWake method works but is simply not defined by default. That code looks fine. Make sure the command is right. Test it by just echoing something in the onWake.

Don't parent it and you won't get that error. It has nothing to parent because it's not a default function with it.

Why test for isPackage? You're creating the package right there, it should always exist

Since you're defining the method for your own named GUI like that (which is the common approach), not calling the parent is completely fine. However, for special cases (such as GuiMouseEventCtrl::onMouseEnter), you can place a snippet like this above your package and then call the parent inside of the package just fine (without breaking stuff):

if (!isFunction("GuiMouseEventCtrl", "onMouseEnter")) {
  eval("function GuiMouseEventCtrl::onMouseEnter(){}");

(damnit, why is Evar's laptop signed into Evar's account on BLF :p)