Thread Tools Display Modes
11/15/14, 10:18 AM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Add context menu (right-click) to ZO_ListDialog1

Hi there,

is it possible to add a context menu (right click menu) to any control, that is already existing in the standard ESO game?
e.g. I try to add a right click menu to ZO_ListDialog1.

I've tried it with AddMenuItem but wasn#t able to pre-hook the ZO_ListDialog1 entries.

Any ideas how to do this?

Thank you for your help.

Baertram
  Reply With Quote
11/15/14, 02:01 PM   #2
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
I believe ingeniousclown's Item Saver does this; you can take a look and see how.
  Reply With Quote
11/16/14, 07:53 AM   #3
QuadroTony
Banned
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 828
im very interesting in this too, Item Saver hasnt this functionality...
  Reply With Quote
11/16/14, 09:38 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Unfortunately ItemSaver does not add a context menu to this popup.
It only changes the color of items in the popup window and disables mouse functionality for those items.
But thx for the hint.

Maybe someone knows a way to just add a context menu to some other control?
e.g. I add a texture and if I right click the texture a context menu will popup showing me 2 added selections?
  Reply With Quote
11/16/14, 11:41 AM   #5
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Lua Code:
  1. control:SetHandler("OnClicked", function(control, button)
  2.     if button == 2 -- RMB==2, LMB==1
  3.         ClearMenu()
  4.         AddMenuItem("quick brown", function() d("fox") end)
  5.         AddMenuItem("lazy", function() d("dog") end)
  6.         ShowMenu(control)
  7.     end
  8. end)
  Reply With Quote
11/16/14, 11:46 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Thx merlight, I'll try this!
  Reply With Quote
11/16/14, 01:03 PM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
It does not work :-( I can see the texture move a bit to the bottm (??) inside the popup dialog.
But nothing happens if I click it.

I tried several things, like disable the mouse button check, or simply add a text message onClicked.

Here is the code I used as the texture (control) is added to the list dialog at popup ZO_ListDialog1:
Code:
-- The current control is a texture at a popup dialog ZO_ListDialog1 (crafting station research popup e.g.)
        if (string.find(parent:GetName(), "ZO_ListDialog1")) then
        	-- Set onClicked handler for right mouse button at textures in popup dialog and show context menu
			control:SetHandler("OnClicked", function(control, button)
			    --if button == 1 then 	-- RMB==2, LMB==1
        			d("Clicked: " .. control:GetName())
			        ClearMenu()
			        AddMenuItem("quick brown", function() d("fox") end)
			        AddMenuItem("lazy", function() d("dog") end)
			        ShowMenu(control)
			    --end
			end)
		end
The only thing that happens if I click the texture is, that the texture moves a bit up again to the place where it is shown normally (without this extra source code).
  Reply With Quote
11/16/14, 01:34 PM   #8
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
That's weird, it shouldn't do anything to placement. Forgot to say that a control must have mouse enabled to catch clicks: control:SetMouseEnabled(true)
  Reply With Quote
11/16/14, 01:57 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Weird. I've tested with /zgoo mouse to see if the texture's variables and methods are ok.

SetHidden(false) was set:
-IsHidden = true ? But I can see it in the popup o0
-IsControlHidden = false -> Maybe this is why I can see it then....
-IsHandlerSet = false ? contol:SetHandler was done...

Do I have to pre-hook the SetHandler somehow so it will work?
  Reply With Quote
11/16/14, 03:16 PM   #10
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Baertram View Post
Code:
-- The current control is a texture at a popup dialog ZO_ListDialog1 (crafting station research popup e.g.)
        if (string.find(parent:GetName(), "ZO_ListDialog1")) then
I don't understand what you're trying to do here...

Originally Posted by Baertram View Post
Weird. I've tested with /zgoo mouse to see if the texture's variables and methods are ok.

SetHidden(false) was set:
-IsHidden = true ? But I can see it in the popup o0
-IsControlHidden = false -> Maybe this is why I can see it then....
-IsHandlerSet = false ? contol:SetHandler was done...
IsHandlerSet("OnClicked") should return true. Zgoo is not smart enough to know it requires a parameter.

Originally Posted by Baertram View Post
Do I have to pre-hook the SetHandler somehow so it will work?
In short, no. Unless it already has one and you want to add a menu to what it already does.

Better make it simple for a start. Try adding the menu to ZO_PlayerInventoryInfoBarMoney (that's the amount of gold in your inventory).
  Reply With Quote
11/17/14, 12:56 PM   #11
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I don't understand what you're trying to do here...
I'm at my function which creates the textures at this time.
The texture is created and "control" is the variable holding the texture.
Parent is the parent control of the texture.

The function creating the textures is used to create textures inside the inventories, inside craftin stations, inside the player character window, and inside the ListDialog popup ZO_ListDialog1 too.
So I'm checking if the name of the parent of the texture contains the string "ZO_ListDialog1" (because it could be ZO_ListDialog1List1Row1, ZO_ListDialog1List1Row2 or something like that.

I'll try to add the menu to the texture of ZO_PlayerInventoryInfoBarMoney, to test if it works.
  Reply With Quote
11/17/14, 01:33 PM   #12
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
It still does not work:-(

I'm executing the following code once as I press a button from my addon.
The chat message "Found - textureControl" will be written to the chat, so the control was found.
It is mouse enabled and no error message is thrown anywhere. It just doesn#t do anything if I click the money part in the inventory (neither the text nor the graphic).

I tried it with both mouse buttons, enabling the context menu stuff, or (like shown below) commenting it out.

Lua Code:
  1. local textureControl = WINDOW_MANAGER:GetControlByName("ZO_PlayerInventoryInfoBarMoney", "")
  2.         if textureControl ~= nil then
  3.             d("Found - textureControl")
  4.             textureControl:SetMouseEnabled(true)
  5.  
  6.             -- Set onClicked handler for right mouse button at textures in popup dialog and show context menu
  7.             textureControl:SetHandler("OnClicked", function(control, button)
  8.                 --if button == 1 then   -- RMB==2, LMB==1
  9.                     d("Clicked: " .. control:GetName())
  10.                     --ClearMenu()
  11.                     --AddMenuItem("quick brown", function() d("fox") end)
  12.                     --AddMenuItem("lazy", function() d("dog") end)
  13.                     --ShowMenu(control)
  14.                 --end
  15.             end)
  16.         end

Are you able to get it to work if you test it merlight?

Maybe a texture control got no OnClicked handler? Only a button got it?

Last edited by Baertram : 11/17/14 at 01:46 PM.
  Reply With Quote
11/17/14, 01:53 PM   #13
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Ah, silly me. OnClicked only works on Button controls. Use OnMouseUp then:
Lua Code:
  1. tex:SetHandler("OnMouseUp", function(control, button, upInside)
  2.     if button == 2 and upInside then
  3.         ...
  4.     end)
  Reply With Quote
11/17/14, 02:04 PM   #14
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
My hero! It works now! Many many thanks!!!
i'll try to put it into the popup dialog now somehow.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Add context menu (right-click) to ZO_ListDialog1


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