Windows Resizing Event.

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Windows Resizing Event.

Post by tsuujin »

So I'm reading though the manual and I find myself a great piece of code, in the form of a function that is called each time the window is manually resized; one that you simply have to polymorph into usable code for your system.

Highly excited, I rush to my system and write a small function that updates my map position on the handleWindowResizeEvent(), as per the manual... to high disappointment when nothing happens.

Is this not implemented yet? Has it been made obsolete with a true event?

using linux pre1.0.6.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Windows Resizing Event.

Post by Heiko »

If you have multiple windows that you want to resize automatically, you'll write your own copy of this function and raise an event. The default function does nothing. Then you'll write a resize event handler for all the windows that you want to resize.
Note that the next version of Mudlet will raise a system event called "sysWindowResize". The custom event handlers will be left untouched for backward compatibility.
Currently you can do:

Code: Select all

handleWindowResizeEvent()
    raiseEvent("onWindowResize")
end


myCoolWindowAHandleResize()
    resizeWindow( ... )
    moveWindow( ... )
end


myCoolWindowBHandleResize()
    resizeWindow( ... )
    moveWindow( ... )
end


myCoolWindowCHandleResize()
    resizeWindow( ... )
    moveWindow( ... )
end

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Windows Resizing Event.

Post by tsuujin »

Right, the problem I'm having is that the function is never being called (which I've tested with debugging echos). When I resize the main window, I get no activity from handleWindowResizeEvent()

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Windows Resizing Event.

Post by Heiko »

This is some working code from Demonnic's upcoming Stygian combat system:

Code: Select all

function handleWindowResizeEvent()
  raiseEvent("windowresize")
end
function windowresize() [located in a script called "windowresize" that defines an event handler for the event "windowresize" - note that the event handler function of a script *must* have the same name as the script. Otherwise it will not be called]

Code: Select all

function windowresize() 
  Stygian_resizeCalendar()
  Stygian_resize_prompt()
  mk_map_resize()
  chatStartup()
  createSystemWindow()
  createInventoryWindow()
  createAfflictionWindow()
end
If your function doesnt get called you'll either have 2 copies of that function or made a spelling error. Use the search function and search for handleWindowResizeEvent(). In case of 2 copies: Lua will use the instance that was compiled last.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Windows Resizing Event.

Post by tsuujin »

Well, I double checked that I only have one copy of the function override, and that the spelling is correct. It simply doesn't get the call.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Windows Resizing Event.

Post by tsuujin »

Odd. I deleted the script, rewrote it and tried it again, to no avail.

Restarting Mudlet afterwards, however, caused it to start working perfectly.

Problem solved?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Windows Resizing Event.

Post by Heiko »

Lua is case sensitive.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Windows Resizing Event.

Post by tsuujin »

Aye, I'm aware of that. I'm new to mudlet, but certainly not to Lua. It wasn't a spelling or duplication or caps error. The function simply wasn't getting called until I restarted.

Post Reply