more fixes
This commit is contained in:
parent
41df9b769f
commit
443b24de3e
3 changed files with 24 additions and 11 deletions
|
|
@ -256,6 +256,8 @@ proc redraw*() =
|
|||
else:
|
||||
dodraw()
|
||||
|
||||
proc redrawForce*() = dodraw()
|
||||
|
||||
proc init(ev: Event) =
|
||||
reqFrame(dodraw)
|
||||
|
||||
|
|
@ -263,6 +265,12 @@ proc setRenderer*(renderer: proc (): VNode) =
|
|||
dorender = renderer
|
||||
window.onload = init
|
||||
|
||||
proc setRendererOnly*(renderer: proc (): VNode) =
|
||||
dorender = renderer
|
||||
|
||||
proc setOnloadOnly*() =
|
||||
window.onload = init
|
||||
|
||||
proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) =
|
||||
## Implements the foundation of Karax's event management.
|
||||
## Karax DSL transforms ``tag(onEvent = handler)`` to
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="App"></div>
|
||||
<script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script>
|
||||
<script src="nimcache/nim_uibench.js" type="text/javascript"></script>
|
||||
|
||||
<div id="ROOT"></div>
|
||||
|
||||
<script src="https://localvoid.github.io/uibench-base/0.1.0/uibench.js"></script>
|
||||
<script src="nimcache/nim_uibench.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -26,11 +26,6 @@ type
|
|||
anim: AnimState
|
||||
tree: TreeState
|
||||
|
||||
proc init*(a: cstring, b: cstring) {.importc: "uibench.init", nodecl.}
|
||||
proc run*(a: proc(state: AppState), b: proc(samples: RootRef)) {.importc: "uibench.run", nodecl.}
|
||||
|
||||
init(cstring"Nim-karax", cstring"0.6.1")
|
||||
|
||||
var container = document.getElementById("#App")
|
||||
var appState: AppState
|
||||
|
||||
|
|
@ -98,7 +93,9 @@ proc treeCreateVNode(data: TreeState): VNode =
|
|||
|
||||
|
||||
proc update(): VNode =
|
||||
if appState == nil: return newVNode(VNodeKind.tdiv)
|
||||
if appState == nil:
|
||||
kout cstring"stupid fuck"
|
||||
return newVNode(VNodeKind.tdiv)
|
||||
let location = appState.location
|
||||
var children: VNode = nil
|
||||
if location == cstring"table":
|
||||
|
|
@ -113,15 +110,22 @@ proc update(): VNode =
|
|||
children
|
||||
|
||||
proc a(state: AppState) =
|
||||
kout cstring"setting state here"
|
||||
appState = state
|
||||
redraw()
|
||||
redrawForce()
|
||||
|
||||
proc b(samples: RootRef) =
|
||||
kout cstring"end called"
|
||||
#document.body.innerHTML = cstring"<pre>" & toJson(samples) & cstring"</pre>"
|
||||
#redraw()
|
||||
discard
|
||||
|
||||
kout cstring"updating"
|
||||
setRenderer update
|
||||
proc init*(a: cstring, b: cstring) {.importc: "uibench.init", nodecl.}
|
||||
proc run*(a: proc(state: AppState), b: proc(samples: RootRef)) {.importc: "uibench.run", nodecl.}
|
||||
|
||||
init(cstring"Nim-karax", cstring"0.6.1")
|
||||
|
||||
setRendererOnly update
|
||||
kout cstring"running"
|
||||
|
||||
run(a, b)
|
||||
Loading…
Add table
Add a link
Reference in a new issue