LoTROInterface (http://www.lotrointerface.com/forums/index.php)
-   Interface Help (L) (http://www.lotrointerface.com/forums/forumdisplay.php?f=3)
-   -   Trouble with window not triggering events (http://www.lotrointerface.com/forums/showthread.php?t=3654)

gillothrin 04-17-2017 08:28 AM

Trouble with window not triggering events

I'm having trouble with Lotro.UI.Window events. I understand that there's some sort of caveat here but I seem to miss it.


MyWindow = class(Turbine.UI.Window());
function MyWindow:Constructor()
        self.defaultWidth = 220;
        self.defaultHeight = 100;
        self:SetSize(self.defaultWidth, self.defaultHeight);
        self:SetWantsUpdates(true); -- seems like it doesn't do anything
        local bbg = Turbine.UI.Color(rgb(7),rgb(32),rgb(71));
        self:SetBackColor( bbg );
        --self.MouseDown = function(s,a) debug("MouseDown"); end; -- not working
        self.MouseDown = self.MouseDownHandler; -- not working

function MyWindow:MouseDownHandler(s,a)
--Not working either
--function MyWindow:MouseDown(s,a)
--        Turbine.Shell.WriteLine("MouseDown");

So it paints but there are no events recorded. However any added control to the window works fine. To make sure that the windows answers, do I have to make sure it has a "shadow" control to get the events?


Thurallor 04-17-2017 11:52 AM

First, remove the "()" after Turbine.UI.Window in the first line. You're not deriving MyClass from an instance of Turbine.UI.Window, but from the class itself.

Second, if you've set "SetWantUpdates(true)", then you need to define an Update event handler, which will be called at each "tick".

Third, your MouseDown event handler won't get its arguments correctly:


function MyWindow:MouseDownHandler(s,a)
Since you used the ":" notation, the first argument will be silently consumed and assigned to the "self" local variable. You should remove the explicit "s" argument, so the arguments you want will go into "a".

Edit: In case it's not obvious, you also need to create an instance of MyWindow. Add "m = MyWindow();" at the end of your code.

gillothrin 04-17-2017 01:35 PM

The '()' I found out on my own, must have been a typo. Removed that and now it works fine.

The SetWantUpdates(true) was good information, perhaps good to get whats going on in the controls.

And good to know about the event arguments too.

Still struggeling with other aspects but thank you for you reply :)

Garan 04-19-2017 09:27 AM

You should probably work your way through the thread:

it covers all of the basics from HelloWorld to more sophisticated issues such as event handling and cross Apartment communication with a number of code samples. You can also learn a lot from taking apart other plugins and experimenting.

While the thread is a bit old, it's still totally relevant, especially since the API hasn't changed in years (the last update was in November 2014) and according to SSG is not likely to ever get updated again. It was implemented as a volunteer "pet" project of a couple of Turbine devs, none of whom still work for SSG and SSG doesn't have the resources or the inclination to research the existing implementation in order to enhance it.

Thurallor 04-19-2017 10:19 AM

I second Garan's suggestion. That's how I started, and it was very helpful.

That guide, along with the Lua 5.1 manual and the API reference, is all you really need.

All times are GMT -5. The time now is 05:15 AM.

vBulletin® - Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.