Added password entry fields; they are the alternate mode of LineEdit.
This commit is contained in:
parent
04ae299ef0
commit
06fa3a5174
|
@ -154,6 +154,12 @@ func gtk_entry_new() *gtkWidget {
|
||||||
return fromgtkwidget(C.gtk_entry_new())
|
return fromgtkwidget(C.gtk_entry_new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func gtkPasswordEntryNew() *gtkWidget {
|
||||||
|
e := gtk_entry_new()
|
||||||
|
C.gtk_entry_set_visibility(togtkentry(e), C.FALSE)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
func gtk_entry_set_text(widget *gtkWidget, text string) {
|
func gtk_entry_set_text(widget *gtkWidget, text string) {
|
||||||
ctext := C.CString(text)
|
ctext := C.CString(text)
|
||||||
defer C.free(unsafe.Pointer(ctext))
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
|
|
18
lineedit.go
18
lineedit.go
|
@ -9,10 +9,11 @@ import (
|
||||||
type LineEdit struct {
|
type LineEdit struct {
|
||||||
// TODO Typing event
|
// TODO Typing event
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
sysData *sysData
|
sysData *sysData
|
||||||
initText string
|
initText string
|
||||||
|
password bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLineEdit makes a new LineEdit with the specified text.
|
// NewLineEdit makes a new LineEdit with the specified text.
|
||||||
|
@ -23,6 +24,14 @@ func NewLineEdit(text string) *LineEdit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPasswordEdit makes a new LineEdit which allows the user to enter a password.
|
||||||
|
func NewPasswordEdit() *LineEdit {
|
||||||
|
return &LineEdit{
|
||||||
|
sysData: mksysdata(c_lineedit),
|
||||||
|
password: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SetText sets the LineEdit's text.
|
// SetText sets the LineEdit's text.
|
||||||
func (l *LineEdit) SetText(text string) (err error) {
|
func (l *LineEdit) SetText(text string) (err error) {
|
||||||
l.lock.Lock()
|
l.lock.Lock()
|
||||||
|
@ -50,6 +59,7 @@ func (l *LineEdit) make(window *sysData) error {
|
||||||
l.lock.Lock()
|
l.lock.Lock()
|
||||||
defer l.lock.Unlock()
|
defer l.lock.Unlock()
|
||||||
|
|
||||||
|
l.sysData.alternate = l.password
|
||||||
err := l.sysData.make(l.initText, window)
|
err := l.sysData.make(l.initText, window)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,7 +26,8 @@ func TestMain(t *testing.T) {
|
||||||
incButton := NewButton("Inc")
|
incButton := NewButton("Inc")
|
||||||
decButton := NewButton("Dec")
|
decButton := NewButton("Dec")
|
||||||
sincdec := NewStack(Horizontal, incButton, decButton)
|
sincdec := NewStack(Horizontal, incButton, decButton)
|
||||||
s0 := NewStack(Vertical, s2, c, cb1, cb2, e, s3, pbar, sincdec)
|
password := NewPasswordEdit()
|
||||||
|
s0 := NewStack(Vertical, s2, c, cb1, cb2, e, s3, pbar, sincdec, password)
|
||||||
lb1 := NewListbox(true, "Select One", "Or More", "To Continue")
|
lb1 := NewListbox(true, "Select One", "Or More", "To Continue")
|
||||||
lb2 := NewListbox(false, "Select", "Only", "One", "Please")
|
lb2 := NewListbox(false, "Select", "Only", "One", "Please")
|
||||||
i := 0
|
i := 0
|
||||||
|
@ -55,11 +56,12 @@ mainloop:
|
||||||
case <-w.Closing:
|
case <-w.Closing:
|
||||||
break mainloop
|
break mainloop
|
||||||
case <-b.Clicked:
|
case <-b.Clicked:
|
||||||
err = w.SetTitle(fmt.Sprintf("%v | %s | %s | %s",
|
err = w.SetTitle(fmt.Sprintf("%v | %s | %s | %s | %s",
|
||||||
c.Checked(),
|
c.Checked(),
|
||||||
cb1.Selection(),
|
cb1.Selection(),
|
||||||
cb2.Selection(),
|
cb2.Selection(),
|
||||||
e.Text()))
|
e.Text(),
|
||||||
|
password.Text()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ type cSysData struct {
|
||||||
ctype int
|
ctype int
|
||||||
event chan struct{}
|
event chan struct{}
|
||||||
resize func(x int, y int, width int, height int) error
|
resize func(x int, y int, width int, height int) error
|
||||||
alternate bool // editable for Combobox, multi-select for listbox
|
alternate bool // editable for Combobox, multi-select for listbox, password for lineedit
|
||||||
}
|
}
|
||||||
func (c *cSysData) make(initText string, window *sysData) error {
|
func (c *cSysData) make(initText string, window *sysData) error {
|
||||||
panic(runtime.GOOS + " sysData does not define make()")
|
panic(runtime.GOOS + " sysData does not define make()")
|
||||||
|
|
|
@ -86,6 +86,7 @@ var classTypes = [nctypes]*classData{
|
||||||
},
|
},
|
||||||
c_lineedit: &classData{
|
c_lineedit: &classData{
|
||||||
make: gtk_entry_new,
|
make: gtk_entry_new,
|
||||||
|
makeAlt: gtkPasswordEntryNew,
|
||||||
setText: gtk_entry_set_text,
|
setText: gtk_entry_set_text,
|
||||||
text: gtk_entry_get_text,
|
text: gtk_entry_get_text,
|
||||||
},
|
},
|
||||||
|
|
|
@ -70,6 +70,7 @@ var classTypes = [nctypes]*classData{
|
||||||
name: "EDIT",
|
name: "EDIT",
|
||||||
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
|
altStyle: _ES_PASSWORD | _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
||||||
font: &controlFont,
|
font: &controlFont,
|
||||||
},
|
},
|
||||||
c_label: &classData{
|
c_label: &classData{
|
||||||
|
|
3
todo.md
3
todo.md
|
@ -5,8 +5,9 @@ so I don't forget:
|
||||||
- determine if a selection in a non-editable combobox has been made
|
- determine if a selection in a non-editable combobox has been made
|
||||||
- see if we really need to track errors on Combobox.Selection()
|
- see if we really need to track errors on Combobox.Selection()
|
||||||
- in fact, see if we really need to track errors on a lot of things...
|
- in fact, see if we really need to track errors on a lot of things...
|
||||||
- password entry fields, character-limited entry fields, numeric entry fields, multiline entry fields
|
- character-limited entry fields, numeric entry fields, multiline entry fields
|
||||||
- possible rename of LineEdit?
|
- possible rename of LineEdit?
|
||||||
|
- especially for password fields - NewPasswordEntry()?
|
||||||
- more flexible size appropriation: allow a small button to be at the top of everything in the main() example here
|
- more flexible size appropriation: allow a small button to be at the top of everything in the main() example here
|
||||||
- [Windows] should ListBox have a border style?
|
- [Windows] should ListBox have a border style?
|
||||||
- a different border on LineEdits?
|
- a different border on LineEdits?
|
||||||
|
|
Loading…
Reference in New Issue