special treatment for input and textarea fields; minor code cleanups
This commit is contained in:
parent
418c027f6c
commit
fe7d72fa4e
3 changed files with 9 additions and 11 deletions
|
|
@ -4,7 +4,6 @@ type TextInput* = ref object of VComponent
|
|||
value: cstring
|
||||
isActive: bool
|
||||
|
||||
var renderId: int
|
||||
proc render(x: VComponent): VNode =
|
||||
let self = TextInput(x)
|
||||
|
||||
|
|
@ -37,18 +36,16 @@ proc render(x: VComponent): VNode =
|
|||
self.isActive = not self.isActive
|
||||
markDirty(self)
|
||||
|
||||
kout cstring"rendering ", self.myid
|
||||
inc renderId
|
||||
result = buildHtml(tdiv(style=style)):
|
||||
input(style=inputStyle, value=self.value, onblur=flip, onfocus=flip)
|
||||
proc onchanged(ev: Event; n: VNode) =
|
||||
kout cstring"onchanged", n.value
|
||||
|
||||
result = buildHtml(tdiv(style=style)):
|
||||
textarea(style=inputStyle, value=self.value, onblur=flip, onfocus=flip, onkeyup=onchanged)
|
||||
|
||||
var gid = 0
|
||||
proc newTextInput*(style: VStyle = VStyle(); value: cstring = cstring""): TextInput =
|
||||
result = newComponent(TextInput, render)
|
||||
result.style = style
|
||||
result.value = value
|
||||
inc gid
|
||||
result.myid = gid
|
||||
|
||||
proc createDom(): VNode =
|
||||
result = buildHtml(tdiv):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue