Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PasswordMode property #393

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add PasswordMode property #393

wants to merge 1 commit into from

Conversation

adongy
Copy link
Contributor

@adongy adongy commented May 21, 2018

Add PasswordMode property to use it in databinding logic.

@lxn
Copy link
Owner

lxn commented May 21, 2018

Could you elaborate a bit in what scenario you need this flexibility? Just asking because every single LineEdit will now use up additional 12 bytes for the EventPublisher plus whatever the Property and it's registration map entry weigh in.

Anyway, it should be possible to create and register properties on demand, so it won't matter much.

Please upgrade the PasswordMode field in declarative.LineEdit from bool to Property.

Also you should call NewBoolProperty, instead of the generic one.

@adongy
Copy link
Contributor Author

adongy commented May 21, 2018

Hi, this is a very valid concern, thanks for taking a look at it.

My use case is a 'Toggle' checkbox.

Take a LineEdit side by side with a Checkbox. By default, PasswordMode is true (hide it from prying eyes let's say). If the user wants to reveal the field, he toggles.

I'm using databinding with Bind("!checkbox.Checked"), instead of:

saving the lineedit reference + checkbox reference (since event handlers don't have access to their callers) and in the state change handler checking the checkbox value then resetting the password mode.

For some reason I also have to invalidate the widget for it to rerender else I have to trigger an event (hovering for example).

You are right about adding dynamically an property, so I think if the cost is too high we can close this.

@lxn
Copy link
Owner

lxn commented May 22, 2018

That's a legit use case.

It seems we need to call win.UpdateWindow or WindowBase.Invalidate at the end of SetPasswordMode.

Sorry, I should have been more clear. Walk should add properties on demand, not the application. It should be possible to modify WindowBase.Property to call some new factory method, if a property of the given name is not registered. Or just add the Property method to Window so it could be "overridden".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants