Page 1 of 1

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

Posted: Tue Jun 12, 2018 9:40 pm
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?

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

Posted: Wed Jun 13, 2018 10:21 am
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

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

Posted: Wed Jun 13, 2018 11:04 am
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.

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

Posted: Wed Jun 13, 2018 11:40 am
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.

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

Posted: Wed Jun 13, 2018 11:51 am
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?

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

Posted: Wed Jun 13, 2018 1:03 pm
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.

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

Posted: Wed Jun 13, 2018 4:07 pm
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?

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

Posted: Wed Jun 13, 2018 4:59 pm
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)

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

Posted: Thu Dec 14, 2023 8:26 pm
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.