Skip to content

Add PasswordMode property #393

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions lineedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ const (

type LineEdit struct {
WidgetBase
editingFinishedPublisher EventPublisher
readOnlyChangedPublisher EventPublisher
textChangedPublisher EventPublisher
charWidthFont *Font
charWidth int
textColor Color
editingFinishedPublisher EventPublisher
readOnlyChangedPublisher EventPublisher
textChangedPublisher EventPublisher
passwordModeChangedPublisher EventPublisher
charWidthFont *Font
charWidth int
textColor Color
}

func newLineEdit(parent Window) (*LineEdit, error) {
Expand Down Expand Up @@ -71,6 +72,16 @@ func newLineEdit(parent Window) (*LineEdit, error) {
},
le.textChangedPublisher.Event()))

le.MustRegisterProperty("PasswordMode", NewProperty(
func() interface{} {
return le.PasswordMode()
},
func(v interface{}) error {
le.SetPasswordMode(v.(bool))
return nil
},
le.passwordModeChangedPublisher.Event()))

return le, nil
}

Expand Down Expand Up @@ -216,8 +227,10 @@ func (le *LineEdit) SetPasswordMode(value bool) {
if value {
c = uintptr('*')
}

le.SendMessage(win.EM_SETPASSWORDCHAR, c, 0)

le.passwordModeChangedPublisher.Publish()
}

func (le *LineEdit) ReadOnly() bool {
Expand Down