Quantcast Trouble with window not triggering events - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > General Discussion & Support > Interface Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 04-17-2017, 08:28 AM
gillothrin gillothrin is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Apr 2017
Posts: 6
Trouble with window not triggering events

Hello,

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.

Code:
MyWindow = class(Turbine.UI.Window());
function MyWindow:Constructor()
	Turbine.UI.Window.Constructor(self);	
	self.defaultWidth = 220;
	self.defaultHeight = 100;
	self:SetMinimumHeight(self.defaultHeight);
	self:SetSize(self.defaultWidth, self.defaultHeight);
	self:SetMouseVisible(true);
	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:SetPosition(100,100);
	self:SetVisible(true);
	Turbine.Shell.WriteLine((Dump(self.MouseDownHandler));
	--self.MouseDown = function(s,a) debug("MouseDown"); end; -- not working
	self.MouseDown = self.MouseDownHandler; -- not working
end

function MyWindow:MouseDownHandler(s,a)
	Turbine.Shell.WriteLine("MouseDownHandler");
end
--Not working either
--function MyWindow:MouseDown(s,a)
--	Turbine.Shell.WriteLine("MouseDown");
--end
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?

TIA

Last edited by gillothrin : 04-17-2017 at 08:44 AM. Reason: (I've seemed to have posted this in the wrong topic, sorry)
Reply With Quote
  #2  
Unread 04-17-2017, 11:52 AM
Thurallor's Avatar
Thurallor Thurallor is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: May 2013
Posts: 103
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:

Code:
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.

Last edited by Thurallor : 04-17-2017 at 11:59 AM. Reason: added note about instantiation
Reply With Quote
  #3  
Unread 04-17-2017, 01:35 PM
gillothrin gillothrin is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Apr 2017
Posts: 6
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
Reply With Quote
  #4  
Unread 04-19-2017, 09:27 AM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 220
You should probably work your way through the thread:
https://www.lotro.com/forums/showthr...gins-for-Noobs

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.
Reply With Quote
  #5  
Unread 04-19-2017, 10:19 AM
Thurallor's Avatar
Thurallor Thurallor is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: May 2013
Posts: 103
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Events in Lua glafria Lua Programming Help (L) 4 06-21-2016 02:41 PM
Binding events to classes Carentil Lua Programming Help (L) 4 11-18-2013 08:19 AM
Trouble with mailbox window GrimCon XML modification help (L) 2 11-12-2010 02:19 PM
TextBox FocusGained() / FocusLost() events not implemented? Betsiel LotRO Wish List (L) 3 10-06-2010 09:44 PM
[REQ]Buff Missing/Triggering Fixer Interface Requests (L) 1 09-28-2010 12:56 AM


All times are GMT -5. The time now is 11:53 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui