Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raylib misses mouse clicks on MacOSX #487

Open
timo-scaleio opened this issue Feb 2, 2025 · 1 comment
Open

Raylib misses mouse clicks on MacOSX #487

timo-scaleio opened this issue Feb 2, 2025 · 1 comment

Comments

@timo-scaleio
Copy link

timo-scaleio commented Feb 2, 2025

Hi there,

when I run the code below on Mac my mouse clicks are missed when I click "briefly". This only prints when I hold the mouse button for a bit.

I tested this in other apps to make sure my systems isn't at high load or something else is going on and I can spam click the mouse and the other apps react accordingly.

package main

import (
	"fmt"
	rl "github.com/gen2brain/raylib-go/raylib"
)

const (
	windowTitle         = "Test"
	defaultScreenWidth  = 1024
	defaultScreenHeight = 720
)

var (
	screenWidth  int32 = defaultScreenWidth
	screenHeight int32 = defaultScreenHeight
)

func watchWindowResize() {
	screenWidth = int32(rl.GetScreenWidth())
	screenHeight = int32(rl.GetScreenHeight())
}

func watchUserInput() {
	if rl.IsMouseButtonPressed(rl.MouseButtonLeft) {
		fmt.Printf("left mouse button pressed\n")
	}

	if rl.IsMouseButtonDown(rl.MouseButtonLeft) {
		fmt.Printf("left mouse button down\n")
	}

	if rl.IsMouseButtonUp(rl.MouseButtonLeft) {
		//fmt.Printf("left mouse button up\n")
	}

	if rl.IsMouseButtonReleased(rl.MouseButtonLeft) {
		fmt.Printf("left mouse button released\n")
	}
}

func main() {
	rl.SetConfigFlags(rl.FlagWindowResizable)
	rl.InitWindow(screenWidth, screenHeight, windowTitle)
	rl.SetTargetFPS(144)

	//rl.EnableEventWaiting()

	camera := rl.Camera3D{
		Position:   rl.NewVector3(0.0, 0.0, 0.0),
		Target:     rl.NewVector3(0.0, 0.0, 0.0),
		Up:         rl.NewVector3(0.0, 1.0, 0.0),
		Fovy:       45.0,
		Projection: rl.CameraPerspective,
	}

	for !rl.WindowShouldClose() {
		watchWindowResize()
		watchUserInput()

		rl.BeginDrawing()
		rl.ClearBackground(rl.RayWhite)

		rl.BeginMode3D(camera)

		rl.EndMode3D()

		rl.DrawFPS(10, 10)

		rl.EndDrawing()
	}

	rl.CloseWindow()
}

When I enable this:

//rl.EnableEventWaiting()

It works but obviously that has undesirable consquences.

@timo-scaleio
Copy link
Author

This has actually be "upgraded" to a Raylib issue.

raysan5/raylib#4749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant