[0.15.33] Disabled GUI element produces empty on_click event

Bugs that are actually features.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[0.15.33] Disabled GUI element produces empty on_click event

Post by eradicator »

Behavior:

Clicking the preperated gui element raises an on_gui_click event but the event.element does not have a .name or a .parent (did not check for further properties) despite evaluating .valid as true.

Reproduction:

1) Create a new GUI element (i.e. a button)
2) Set .enabled=false on the highest of it's parents (the disabled element must not have any visible or invisible elements behind it (i.e. frames, flows, etc).
3) Make sure that no entities are behind the element, game.player.selected must be nil for the bug to occur.
4) Click the GUI element, which will cause on_gui_click to be raised like described in "Behavior".

Code: Select all

local function test_center_gui(LuaPlayer)
  --clicking either frame or button will cause the bug
  LuaPlayer.gui.center.add{name='parentttt',type='flow',enabled=false}
                      .add{name='frame',type='frame'}
                      .add{name='button',type='button',style='slot_button_style'}
  end
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.15.33] Disabled GUI element produces empty on_click event

Post by kovarex »

The element that is received is the root element center that contains all the elements added to center.
To avoid the confusion in the future, I changed, that these root elements have their widget name set up correctly for 0.16

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

Re: [0.15.33] Disabled GUI element produces empty on_click event

Post by eradicator »

Oh. Heh. Yea, that would do it. I didn't expect the root itself to raise that event.

Thanks for the answer tho ;)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Not a bug”