-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9d94b0
commit 9f2b6c4
Showing
3 changed files
with
16 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
import fenstim | ||
import fenstim, strutils | ||
|
||
var | ||
app = init(Fenster, "Mouse Buttons test", 800, 600) | ||
lastMouseX, lastMouseY = -1 | ||
lastClickStates: array[5, int] | ||
lastHoldStates: array[3, int] | ||
prevMClick = app.mclick | ||
prevMHold = app.mhold | ||
|
||
while app.loop and app.keys[27] == 0: | ||
let (mouseX, mouseY, clickStates, holdStates) = app.mouse | ||
#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 | ||
|
||
let positionChanged = [mouseX, mouseY] != [lastMouseX, lastMouseY] | ||
let clickChanged = clickStates != lastClickStates | ||
let holdChanged = holdStates != lastHoldStates | ||
|
||
if positionChanged or clickChanged or holdChanged: | ||
echo "Mouse position: (", mouseX, ", ", mouseY, ")" | ||
echo "Click states: ", clickStates | ||
echo "Hold states: ", holdStates | ||
|
||
echo "--------------------" | ||
|
||
lastMouseX = mouseX | ||
lastMouseY = mouseY | ||
lastClickStates = clickStates | ||
lastHoldStates = holdStates | ||
|
||
app.close | ||
echo "-".repeat(15) | ||
|
||
prevMClick = app.mclick | ||
prevMHold = app.mhold |
Submodule fensterb
updated
6 files
+6 −1 | README.md | |
+3 −23 | examples/mousebuttons-c/main.c | |
+2 −10 | src/fenster/fenster.h | |
+9 −8 | src/fenster/fenster_linux.h | |
+9 −8 | src/fenster/fenster_mac.h | |
+9 −8 | src/fenster/fenster_windows.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters