godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.11k stars 69 forks source link

Add a `checked` parameter to `PopupMenu.add_check_item()` to make new check items pressed by default #2640

Open wajrou opened 3 years ago

wajrou commented 3 years ago

Describe the project you are working on

Describe the problem or limitation you are having in your project

PopupMenu.add_check_item() should have param checked.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It allows to add checked item, without searching for idx and checking after when checked state is initial.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

var menu = PopupMenu.new()
menu.add_check_item(..., true)
menu.add_radio_check_item(..., true)

If this enhancement will not be used often, can it be worked around with a few lines of script?

Is there a reason why this should be core and not an add-on in the asset library?

wajrou commented 3 years ago

It's maybe not so simple when there are other useful flags than checked for checkboxes and radio buttons like disabled (for all PopupMenu items). int flags could be better solution (with constants PopupMenu.ITEM_CHECKED, ITEM_DISABLED, ...) to add item with initial states than only bool checked param.