Skip to content

Commit

Permalink
Fix mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
CardealRusso committed Oct 16, 2024
1 parent 9f2b6c4 commit a0f11e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
15 changes: 4 additions & 11 deletions examples/mouse_buttons.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@ import fenstim, strutils

var
app = init(Fenster, "Mouse Buttons test", 800, 600)
prevMClick = app.mclick
prevMHold = app.mhold
oldmouse = app.mouse

while app.loop and app.keys[27] == 0:
#It doesn't matter if you call app.m* several times in the same loop, since the value will only change in the next loop
if app.mclick != prevMClick or app.mhold != prevMHold:
echo "Clicks: ", app.mclick
echo "HOlding: ", app.mhold

echo "-".repeat(15)

prevMClick = app.mclick
prevMHold = app.mhold
if oldmouse != app.mouse:
oldmouse = app.mouse
echo app.mouse
8 changes: 6 additions & 2 deletions src/fenstim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ template width*(self: Fenster): int = self.raw.width.int
template height*(self: Fenster): int = self.raw.height.int
template keys*(self: Fenster): array[256, cint] = self.raw.keys
template modkey*(self: Fenster): int = self.raw.modkey.int
template mclick*(self: Fenster): array[5, cint] = self.raw.mclick
template mhold*(self: Fenster): array[3, cint] = self.raw.mhold
template mouse*(self: Fenster): tuple[pos: tuple[x, y: int], mclick: array[5, cint], mhold: array[3, cint]] =
(
pos: (x: self.raw.x.int, y: self.raw.y.int),
mclick: self.raw.mclick,
mhold: self.raw.mhold
)
proc sleep*(self: Fenster, ms: int) = fenster_sleep(ms.cint)
proc time*(self: Fenster): int64 = fenster_time()

Expand Down

0 comments on commit a0f11e0

Please sign in to comment.