ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Add context menu (right-click) to ZO_ListDialog1 (https://www.esoui.com/forums/showthread.php?t=2439)

Baertram 11/15/14 10:18 AM

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

katkat42 11/15/14 02:01 PM

I believe ingeniousclown's Item Saver does this; you can take a look and see how.

QuadroTony 11/16/14 07:53 AM

im very interesting in this too, Item Saver hasnt this functionality...:o

Baertram 11/16/14 09:38 AM

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?

merlight 11/16/14 11:41 AM

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)

Baertram 11/16/14 11:46 AM

Thx merlight, I'll try this!

Baertram 11/16/14 01:03 PM

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).

merlight 11/16/14 01:34 PM

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)

Baertram 11/16/14 01:57 PM

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?

merlight 11/16/14 03:16 PM

Quote:

Originally Posted by Baertram (Post 13280)
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...

Quote:

Originally Posted by Baertram (Post 13282)
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.

Quote:

Originally Posted by Baertram (Post 13282)
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).

Baertram 11/17/14 12:56 PM

Quote:

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.

Baertram 11/17/14 01:33 PM

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?

merlight 11/17/14 01:53 PM

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)

Baertram 11/17/14 02:04 PM

My hero! It works now! Many many thanks!!!
i'll try to put it into the popup dialog now somehow.


All times are GMT -6. The time now is 09:31 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI