Implemented TextField on Windows.

This commit is contained in:
Pietro Gagliardi 2014-07-26 06:57:11 -04:00
parent 52e75e6cce
commit 4515849e22
3 changed files with 37 additions and 0 deletions

View File

@ -15,6 +15,7 @@ On Windows, container controls are just regular controls; their children have to
TODO
- make sure all tabs cannot be deselected (that is, make sure the current tab can never have index -1)
- make sure tabs initially show the right control
- for some reason the text entry tabs show the checkbox tab until the checkbox tab is clicked, THEN they show their proper contents
*/
type tab struct {

View File

@ -125,3 +125,35 @@ func checkboxToggled(data unsafe.Pointer) {
c.clicked.fire()
println("checkbox toggled")
}
type textField struct {
*widgetbase
}
var editclass = toUTF16("EDIT")
func startNewTextField(style C.DWORD) *textField {
w := newWidget(editclass,
style | C.ES_LEFT | C.ES_NOHIDESEL | C.WS_BORDER | C.WS_TABSTOP,
C.WS_EX_CLIENTEDGE)
C.controlSetControlFont(w.hwnd)
return &textField{
widgetbase: w,
}
}
func newTextField() *textField {
return startNewTextField(0)
}
func newPasswordField() *textField {
return startNewTextField(C.ES_PASSWORD)
}
func (t *textField) Text() string {
return t.text()
}
func (t *textField) SetText(text string) {
t.settext(text)
}

View File

@ -48,6 +48,10 @@ func init() {
w.SetTitle(fmt.Sprint(c.Checked()))
})
t.Append("Checkbox", c)
e := NewTextField()
t.Append("Text Field", e)
e = NewPasswordField()
t.Append("Password Field", e)
w.Show()
})
<-done