View Single Post
  #2  
Unread 09-08-2012, 01:00 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 341
There is an example of masking a quickslot behind another control to simulate a quickslot button in the Writing LotRO Plugins for Noobs thread:
http://forums.lotro.com/showthread.p...91#post5824491
The third button example is the quickslot. You can also find similar code in the MoorMap main.lua file to implement the Quick Annotation tool as well as in many other plugins, Plugin Compendium which uses quickslots behind labels to send text to chat comes to mind. I'm sure there are many other examples.

It's usually overkill to put an actual Button in front of the quickslot since you need to use SetMouseVisible(false) on the masking object so that mouse events go through to the quickslot. However, I can think of at least one case where I have put a real button in front and by controlling its mouse visibility was able to implement some neat functionality. Typically though, you would either use a Control object and just set a background image to make it look like a button or use a Label object if you want text.

Here's some additional comments I recently sent to another user regarding using quickslots masked behind other controls:
Quote:
Now, as to hiding a quickslot behind another control, there are a few tricks:
First, you need to size the quickslot 34 pixels wider and higher than the control it will be behind and then position it 34 pixels to the left and above. This will prevent the "/A" icon in the quickslot from displaying through the control in front of it.
Second, you need to prevent the user's ability to drag and drop. You partially took care of this with the "tmpControl:SetAllowDrop(false);" line, but that doesn't prevent the user from accidentally dragging your alias OUT of the control. To prevent that, you need to save the correct alias text in a property of the control and then set the "tmpControl.DragDrop" function to restore the correct alias, effectively preventing it from being dragged out.
Third, you need to make the control in front of the quickslot ignore mouse events using the SetMouseVisible(false) method.
Fourth, there is (or was, I haven't checked lately) a bug in the constructor of quickslot shortcuts which would fail to process special characters (non-ASCII) correctly. For this reason, you should always create shortcuts with an empty string and then assign the text using the SetData() method.
Basically, your sample would become:
Code:
-- Create Emote Button
myWindow.EmoteButton=Turbine.UI.Label();
myWindow.EmoteButton:SetParent(myWindow);
myWindow.EmoteButton:SetSize(190,30);
myWindow.EmoteButton:SetPosition(myWindow:GetWidth()/4+30,265)
myWindow.EmoteButton:SetText("Send Emote");
myWindow.EmoteButton:SetBackColor(Turbine.UI.Color(0,0,0)); -- needed to prevent the quickslot icon boundary from displaying
myWindow.EmoteButton:SetMouseVisible(false);

myWindow.EmoteQSBack=Turbine.UI.Control(); -- used to prevent the quickslot from drawing outside the mask bounds
myWindow.EmoteQSBack:SetParent(myWindow);
myWindow.EmoteQSBack:SetSize(myWindow.EmoteButton:GetWidth(),myWindow.EmoteButton:GetHeight())
myWindow.EmoteQSBack:SetPosition(myWindow.EmoteButton:GetLeft(),myWindow.EmoteButton:GetTop())
myWindow.EmoteQSBack:SetZOrder(-1);
myWindow.EmoteQS = Turbine.UI.Lotro.Quickslot();
myWindow.EmoteQS:SetParent(myWindow.EmoteQSBack);
myWindow.EmoteQS:SetShortcut(Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Alias, "/flirt"));
 -- note, if there is any chance that the alias could contain a special (non-ASCII) character then you should use the SetData method to assign it to avoid a bug in the Shortcut constructor
myWindow.EmoteQS:SetSize(myWindow.EmoteButton:GetWidth()+34,myWindow.EmoteButton:GetHeight()+34)
myWindow.EmoteQS:SetPosition(-34,-34);
myWindow.EmoteQS.AliasText="/flirt";
myWindow.EmoteQS:SetAllowDrop(false);
myWindow.EmoteQS.DragDrop=function(sender)
     local sc=Turbine.UI.Lotro.Shortcut(Turbine.UI.Lotro.ShortcutType.Alias,"");
     sc:SetData("/flirt");
     sender:SetShortcut(sc);
end

Last edited by Garan : 09-08-2012 at 01:32 PM.
Reply With Quote