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

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

Postby _npo6ka_ » Tue Jun 12, 2018 9:40 pm

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?
_npo6ka_
Long Handed Inserter
Long Handed Inserter
 
Posts: 84
Joined: Mon Sep 26, 2016 10:29 pm

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

Postby Rseding91 » Wed Jun 13, 2018 10:21 am

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 IRC and Discord.
Rseding91
Factorio Staff
Factorio Staff
 
Posts: 7692
Joined: Wed Jun 11, 2014 5:23 am

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

Postby eradicator » Wed Jun 13, 2018 11:04 am

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.
User avatar
eradicator
Smart Inserter
Smart Inserter
 
Posts: 1904
Joined: Tue Jul 12, 2016 9:03 am
Location: Mod support languages: JA/DE/EN

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

Postby Rseding91 » Wed Jun 13, 2018 11:40 am

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 IRC and Discord.
Rseding91
Factorio Staff
Factorio Staff
 
Posts: 7692
Joined: Wed Jun 11, 2014 5:23 am

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

Postby eradicator » Wed Jun 13, 2018 11:51 am

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?
User avatar
eradicator
Smart Inserter
Smart Inserter
 
Posts: 1904
Joined: Tue Jul 12, 2016 9:03 am
Location: Mod support languages: JA/DE/EN

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

Postby Rseding91 » Wed Jun 13, 2018 1:03 pm

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 IRC and Discord.
Rseding91
Factorio Staff
Factorio Staff
 
Posts: 7692
Joined: Wed Jun 11, 2014 5:23 am

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

Postby eradicator » Wed Jun 13, 2018 4:07 pm

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?
User avatar
eradicator
Smart Inserter
Smart Inserter
 
Posts: 1904
Joined: Tue Jul 12, 2016 9:03 am
Location: Mod support languages: JA/DE/EN

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

Postby _npo6ka_ » Wed Jun 13, 2018 4:59 pm

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)
_npo6ka_
Long Handed Inserter
Long Handed Inserter
 
Posts: 84
Joined: Mon Sep 26, 2016 10:29 pm


Return to Modding interface requests

Who is online

Users browsing this forum: No registered users and 1 guest