[0.16.x] Choose-element-button middle mouse click event

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

[0.16.x] Choose-element-button middle mouse click event

Post by _npo6ka_ »

Currently only 2 types of LuaGuiElement("button" or "sprite-button") can use the middle mouse button and buttons 4-9.

I quite often use in my fashion FNEI "choose-element-button" with the property "locked = true". When using "choose-element-button", the user can point to such button and in the tooltip see complete information about the recipe or the item. It is very convenient. However, the game's API does not support reading by pressing the middle mouse button. I do not really understand why you did not add this type of button? And in general, all elements have the right-click and left-click events, why you did not add "mouse_button_filter" for all LuaGuiElement?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by Rseding91 »

You can already do this. You just have to set the mouse button filter on the element to respond to what buttons you want: http://lua-api.factorio.com/latest/LuaG ... ton_filter
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by eradicator »

No you can't. Choose-button errors when attempting to set a mouse filter:

Code: Select all

/c a = game.player.gui.center.add{type='choose-elem-button',elem_type='item'} a.mouse_button_filter =  {'left','right','middle'}

Code: Select all

"Error: Expected button or sprite-button."
I also noticed that normal buttons default to {'left','right'} and have to be explicitily changed to accept middle.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by Rseding91 »

eradicator wrote:No you can't. Choose-button errors when attempting to set a mouse filter:

Code: Select all

/c a = game.player.gui.center.add{type='choose-elem-button',elem_type='item'} a.mouse_button_filter =  {'left','right','middle'}

Code: Select all

"Error: Expected button or sprite-button."
I also noticed that normal buttons default to {'left','right'} and have to be explicitily changed to accept middle.
Ah right. Every widget does support mouse button filter but things like the choose elem button are hard coded to react to specific mouse buttons so clicking them with other buttons doesn't do anything.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by eradicator »

Rseding91 wrote:Ah right. Every widget does support mouse button filter but things like the choose elem button are hard coded to react to specific mouse buttons so clicking them with other buttons doesn't do anything.
Clicking it with left button is inconsistent with the base game gui though, where filters are set with middle mouse button. I wish we could just override the button. But...anyway, the real issue here is that abusing the choose-element-button is the only way to get a vanilla style item tooltip for a button. So how feasible is it to allow specifying vanilla tooptips for other gui elements? I.e. tooltip = 'item/iron-plate', or allowing us to make properly formated tooltips?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by Rseding91 »

eradicator wrote:
Rseding91 wrote:Ah right. Every widget does support mouse button filter but things like the choose elem button are hard coded to react to specific mouse buttons so clicking them with other buttons doesn't do anything.
Clicking it with left button is inconsistent with the base game gui though, where filters are set with middle mouse button. I wish we could just override the button. But...anyway, the real issue here is that abusing the choose-element-button is the only way to get a vanilla style item tooltip for a button. So how feasible is it to allow specifying vanilla tooptips for other gui elements? I.e. tooltip = 'item/iron-plate', or allowing us to make properly formated tooltips?
No it isn't. A choose-elem-button is not an inventory-with-filters button. A choose-elem-button is the same as the deconstruction planner filters - they're literally the same underlying widget.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by eradicator »

Rseding91 wrote:
eradicator wrote:
Rseding91 wrote:Ah right. Every widget does support mouse button filter but things like the choose elem button are hard coded to react to specific mouse buttons so clicking them with other buttons doesn't do anything.
Clicking it with left button is inconsistent with the base game gui though, where filters are set with middle mouse button. I wish we could just override the button. But...anyway, the real issue here is that abusing the choose-element-button is the only way to get a vanilla style item tooltip for a button. So how feasible is it to allow specifying vanilla tooptips for other gui elements? I.e. tooltip = 'item/iron-plate', or allowing us to make properly formated tooltips?
No it isn't. A choose-elem-button is not an inventory-with-filters button. A choose-elem-button is the same as the deconstruction planner filters - they're literally the same underlying widget.
We modders don't have access to inventory-with-filters though (as far as i remember because of the linked ItemStack, so i don't even dare to ask to make that accessible...), besides it wouldn't fit this topics particular usecase. So we have to resuse other element types, sacrificing things here and there to get close to the behavior we need. And this is one of the cases where there's only bad compromises.
So, what about the other question about better tooltips?

_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by _npo6ka_ »

eradicator wrote:
Rseding91 wrote:
eradicator wrote:
Rseding91 wrote:Ah right. Every widget does support mouse button filter but things like the choose elem button are hard coded to react to specific mouse buttons so clicking them with other buttons doesn't do anything.
Clicking it with left button is inconsistent with the base game gui though, where filters are set with middle mouse button. I wish we could just override the button. But...anyway, the real issue here is that abusing the choose-element-button is the only way to get a vanilla style item tooltip for a button. So how feasible is it to allow specifying vanilla tooptips for other gui elements? I.e. tooltip = 'item/iron-plate', or allowing us to make properly formated tooltips?
No it isn't. A choose-elem-button is not an inventory-with-filters button. A choose-elem-button is the same as the deconstruction planner filters - they're literally the same underlying widget.
We modders don't have access to inventory-with-filters though (as far as i remember because of the linked ItemStack, so i don't even dare to ask to make that accessible...), besides it wouldn't fit this topics particular usecase. So we have to resuse other element types, sacrificing things here and there to get close to the behavior we need. And this is one of the cases where there's only bad compromises.
So, what about the other question about better tooltips?
better tooltips would be the best solution to my problem)

Soul-Burn
Inserter
Inserter
Posts: 28
Joined: Sun Jan 31, 2021 9:07 pm
Contact:

Re: [0.16.x] Choose-element-button middle mouse click event

Post by Soul-Burn »

Another request for this feature.

In the mod FilterHelper, we do interactions of all 3 mouse buttons, using sprite-button.
I want to add support for Q on the buttons when using Cursor Enhancements (or 2.0's Q on anything feature), and found that the way to do it is with a locked choose-elem-button as above. However, this then stops us from using the middle button, as above.

Post Reply

Return to “Modding interface requests”