Skip to content

Add a disabled state to the button#2008

Closed
bagggage wants to merge 5 commits into
PixelGuys:masterfrom
bagggage:gui
Closed

Add a disabled state to the button#2008
bagggage wants to merge 5 commits into
PixelGuys:masterfrom
bagggage:gui

Conversation

@bagggage

Copy link
Copy Markdown
Contributor

Adds a disabled field to the button struct.
Now any button can be easily disabled by setting button.disabled = true.

image_2025-10-15_00-44-01

@IntegratedQuantum

Copy link
Copy Markdown
Member

What is the motivation for this?

@bagggage

Copy link
Copy Markdown
Contributor Author

What is the motivation for this?

Prevent the receipt of click events in a context where a temporary block or restriction is in effect for that event. Simply put, for example, the user cannot press "Join" to connect to a server as long as the IP address input field is empty, as this is a knowingly unsuccessful event.

The code for handling click events can become simpler now, as there is a kind of guarantee that if a button is pressed, the context is inherently correct.

Secondly, it provides quick visual feedback to the user about the unavailability of an action. Otherwise, for instance, in an invalid context, it would be necessary to provide feedback to the user after the click, such as displaying an error message or a message about invalid input (as in the example above), and this requires additional logic for message delivery and so on.

@IntegratedQuantum

Copy link
Copy Markdown
Member

Could you then please implement this for the Join button? It's easier to review things if I can test them.

@bagggage

Copy link
Copy Markdown
Contributor Author

It's easier to review things if I can test them.

You can test this right now on the server-list (#2017) branch. But if there are any objections, I can implement it for the Join button on the current branch.

@BoySanic

BoySanic commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

It'll be easier to review if you can implement it on a button that exists in the master branch, like the ``Join` button suggestion

@BoySanic BoySanic moved this to In review in PRs to review Nov 3, 2025
@bagggage

bagggage commented Nov 8, 2025

Copy link
Copy Markdown
Contributor Author

It'll be easier to review if you can implement it on a button that exists in the master branch, like the ``Join` button suggestion

Okay, I implemented some network address validation with disabling the join button in the Multiplayer window.

image

Comment thread src/gui/windows/multiplayer.zig Outdated
Comment thread src/gui/windows/multiplayer.zig Outdated
Comment thread src/gui/windows/multiplayer.zig Outdated
else
normalTextures;
draw.setColor(0xff000000);
draw.setColor(if(self.disabled) 0xa0000000 else 0xff000000);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a separate texture, to give more artistic control.

Comment thread src/gui/windows/multiplayer.zig Outdated
IntegratedQuantum added a commit that referenced this pull request Jun 13, 2026
With a reference use-case (showing the social settings that cannot be
changed when in the world, previously they were hidden, now they are
shown as disabled):
<img width="1280" height="745" alt="Screenshot at 2026-06-10 08-51-22"
src="https://github.com/user-attachments/assets/6e606d14-bcf7-470b-a603-20a8804a806e"
/>

To achieve this I made a small change to the button interface to allow
for optional arguments

replaces #2008

fixes #2556

---------

Co-authored-by: Carrie <carriecapp9@gmail.com>
@IntegratedQuantum

Copy link
Copy Markdown
Member

superseded by #3203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants