You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import illwill
import illwillWidgets
import os
# default illwill boilerplateproc exitProc() {.noconv.} =
illwillDeinit()
showCursor()
quit(0)
illwillInit(fullscreen=true, mouse=true) # <- enable mouse support
setControlCHook(exitProc)
hideCursor()
var tb = newTerminalBuffer(terminalWidth(), terminalHeight())
# Create widgetsvar infoBox = newInfoBox("",0 ,0, terminalWidth())
var btnFill = newButton("fill", 38, 3, 15, 2)
var btnClear = newButton("clear", 38, 6, 15, 2)
whiletrue:
var key = getKey()
# Test if the key signals a mouse event.if key == Key.Mouse:
# get the mouse information from illwillvar mi: MouseInfo = getMouse()
# to catch the widgets eventsvar ev: Events
# we must call dispatch on every widget.# dispatch returns events that the widget fires.
ev = tb.dispatch(btnFill, mi)
if ev.contains MouseUp:
# do stuff when mouse button releases
tb.clear("A")
if ev.contains MouseHover:
# do stuff when mouse hover over element
infoBox.text ="Fills the screen!!"# Another button to clear the screen again
ev = tb.dispatch(btnClear, mi)
if ev.contains MouseUp:
# do stuff when mouse button releases
tb.clear()
if ev.contains MouseHover:
# do stuff when mouse hover over element
infoBox.text ="clear the screen"# After dispatching we need to actually render the element# into the terminal buffer
tb.render(btnFill)
tb.render(btnClear)
tb.render(infoBox)
# Draw the terminal buffer to screen.
tb.display()
sleep(25)