diff options
Diffstat (limited to 'redo/textfield_windows.go')
| -rw-r--r-- | redo/textfield_windows.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/redo/textfield_windows.go b/redo/textfield_windows.go index 701c2b6..7345205 100644 --- a/redo/textfield_windows.go +++ b/redo/textfield_windows.go @@ -2,12 +2,17 @@ package ui +import ( + "unsafe" +) + // #include "winapi_windows.h" import "C" type textfield struct { _hwnd C.HWND _textlen C.LONG + changed *event } var editclass = toUTF16("EDIT") @@ -17,9 +22,11 @@ func startNewTextField(style C.DWORD) *textfield { style | C.ES_AUTOHSCROLL | C.ES_LEFT | C.ES_NOHIDESEL | C.WS_TABSTOP, C.WS_EX_CLIENTEDGE) // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) t := &textfield{ - _hwnd: hwnd, + _hwnd: hwnd, + changed: newEvent(), } C.controlSetControlFont(t._hwnd) + C.setTextFieldSubclass(t._hwnd, unsafe.Pointer(t)) return t } @@ -39,6 +46,21 @@ func (t *textfield) SetText(text string) { baseSetText(t, text) } +func (t *textfield) OnChanged(f func()) { + t.changed.set(f) +} + +func (t *textfield) Invalid(reason string) { + // TODO +} + +//export textfieldChanged +func textfieldChanged(data unsafe.Pointer) { + t := (*textfield)(data) +println("changed") + t.changed.fire() +} + func (t *textfield) hwnd() C.HWND { return t._hwnd } |
