summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrustable-code <krauter.simon@arcor.de>2019-09-23 23:20:12 +0200
committertrustable-code <krauter.simon@arcor.de>2019-09-23 23:20:12 +0200
commit0db4b1f8ca9a09875247f4f05ddfb62981d7e5be (patch)
tree38082cba7997ac6998176740cb282c42e7c6a668 /src
parent9d9babe7491f791545ddb7730a573e9b21cd3fa6 (diff)
downloadNiGui-0db4b1f8ca9a09875247f4f05ddfb62981d7e5be.tar.gz
NiGui-0db4b1f8ca9a09875247f4f05ddfb62981d7e5be.zip
Move onTextChange from Control to TextBox
TextChangeEvent is now only available for TextBox and TextArea
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nigui.nim32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/nigui.nim b/src/nigui.nim
index 793d80f..c8480e5 100755
--- a/src/nigui.nim
+++ b/src/nigui.nim
@@ -249,7 +249,6 @@ type
fOnClick: ClickProc
# fOnMouseMove: MouseMoveProc
fOnKeyDown: KeyboardProc
- fOnTextChange: TextChangeProc
tag*: string
# Drawing:
@@ -367,6 +366,8 @@ type
TextBox* = ref object of ControlImpl
fEditable: bool
+ fOnTextChange: TextChangeProc
+
# Platform-specific extension:
when useWindows(): include "nigui/private/windows/platform_types2"
@@ -790,8 +791,6 @@ method handleClickEvent*(control: Control, event: ClickEvent)
method handleKeyDownEvent*(control: Control, event: KeyboardEvent)
-method handleTextChangeEvent*(control: Control, event: TextChangeEvent)
-
method onDispose*(control: Control): ControlDisposeProc
method `onDispose=`*(control: Control, callback: ControlDisposeProc)
@@ -810,9 +809,6 @@ method `onClick=`*(control: Control, callback: ClickProc)
method onKeyDown*(control: Control): KeyboardProc
method `onKeyDown=`*(control: Control, callback: KeyboardProc)
-method onTextChange*(control: Control): TextChangeProc
-method `onTextChange=`*(control: Control, callback: TextChangeProc)
-
# ----------------------------------------------------------------------------------------
# Container
@@ -952,6 +948,11 @@ method `selectionEnd=`*(textBox: TextBox, selectionEnd: int)
method selectedText*(textBox: TextBox): string
method `selectedText=`*(textBox: TextBox, text: string)
+method handleTextChangeEvent*(textBox: TextBox, event: TextChangeEvent)
+
+method onTextChange*(textBox: TextBox): TextChangeProc
+method `onTextChange=`*(textBox: TextBox, callback: TextChangeProc)
+
# ----------------------------------------------------------------------------------------
# TextArea
@@ -1819,12 +1820,6 @@ method handleKeyDownEvent(control: Control, event: KeyboardEvent) =
if callback != nil:
callback(event)
-method handleTextChangeEvent(control: Control, event: TextChangeEvent) =
- # can be overridden by custom control
- let callback = control.onTextChange
- if callback != nil:
- callback(event)
-
method onDispose(control: Control): ControlDisposeProc = control.fOnDispose
method `onDispose=`(control: Control, callback: ControlDisposeProc) = control.fOnDispose = callback
@@ -1843,9 +1838,6 @@ method `onClick=`(control: Control, callback: ClickProc) = control.fOnClick = ca
method onKeyDown(control: Control): KeyboardProc = control.fOnKeyDown
method `onKeyDown=`(control: Control, callback: KeyboardProc) = control.fOnKeyDown = callback
-method onTextChange(control: Control): TextChangeProc = control.fOnTextChange
-method `onTextChange=`(control: Control, callback: TextChangeProc) = control.fOnTextChange = callback
-
# ----------------------------------------------------------------------------------------
# Container
@@ -2535,6 +2527,16 @@ method `selectedText=`(textBox: TextBox, text: string) =
textBox.text = oldText.runeSubStr(0, textBox.selectionStart) & text & oldText.runeSubStr(textBox.selectionEnd)
textBox.cursorPos = oldCursorPos
+method handleTextChangeEvent(textBox: TextBox, event: TextChangeEvent) =
+ # can be overridden by custom control
+ let callback = textBox.onTextChange
+ if callback != nil:
+ callback(event)
+
+method onTextChange(textBox: TextBox): TextChangeProc = textBox.fOnTextChange
+
+method `onTextChange=`(textBox: TextBox, callback: TextChangeProc) = textBox.fOnTextChange = callback
+
# ----------------------------------------------------------------------------------------
# TextArea