Skip to content

Commit

Permalink
Add cursor sample
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Maškarinec <[email protected]>
  • Loading branch information
marekmaskarinec committed Jun 20, 2024
1 parent 77ddf64 commit c12f998
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions samples/cursor/main.um
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import (
"canvas.um"
"window.um"
"th.um"
"input.um"
)

cursor := 0

fn init*() {
window::setup("Cursor Sample", 400, 400)

window::onFrame.register({
cursor += trunc(input::getMouseScroll().y) > 0 ? 1 : 0
cursor += trunc(input::getMouseScroll().y) < 0 ? -1 : 0
cursor %= int(window::Cursor.count_)
cursor = cursor < 0 ? 0 : cursor
window::setCursor(window::Cursor(cursor))
canvas::drawText(sprintf("Select cursor with\nscrollwheel: %d", cursor), {10, 10}, th::red, 3)
})
}

0 comments on commit c12f998

Please sign in to comment.