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

GuiWindowBox --> num #27

Open
satarics opened this issue May 26, 2024 · 0 comments
Open

GuiWindowBox --> num #27

satarics opened this issue May 26, 2024 · 0 comments

Comments

@satarics
Copy link

examples gui_portable_window.lua:

#!/home/maik_ubn/raylib-lua/raylua_s

local width, height = 1280, 720

rl.SetConfigFlags(rl.FLAG_WINDOW_UNDECORATED)
rl.InitWindow(width, height, "raygui - portable window")
rl.SetTargetFPS(75)

local mouse_pos = rl.new("Vector2", 0, 0)
local window_pos = rl.GetWindowPosition()
local pan_offset = rl.new("Vector2", mouse_pos)

local drag_window = false
local exit_window = false

while not exit_window and not rl.WindowShouldClose() do
  print(exit_window, rl.WindowShouldClose()) --> false   false
  mouse_pos = rl.GetMousePosition()
  
  if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) then
    if rl.CheckCollisionPointRec(mouse_pos, rl.new("Rectangle", 0, 0, width, 20)) then
      drag_window = true
      pan_offset = rl.new("Vector2", mouse_pos)
    end
  end
  
  if drag_window then
    window_pos = window_pos + mouse_pos - pan_offset
    
    if rl.IsMouseButtonReleased(rl.MOUSE_BUTTON_RIGHT) then
      drag_window = false
    end
    
    rl.SetWindowPosition(window_pos.x, window_pos.y)
  end
    
  rl.BeginDrawing()
  
  rl.ClearBackground(rl.RAYWHITE)
  exit_window = rl.GuiWindowBox(rl.new("Rectangle", 0, 0, width, height), "PORTABLE WINDOW") -- return num
  rl.DrawText(string.format("Mouse Position: [ %.0f, %.0f ]", mouse_pos.x, mouse_pos.y),
    10, 40, 10, rl.DARKGRAY)

  rl.EndDrawing()

  print(exit_window, rl.WindowShouldClose()) --> 0, false --> not exit_window --> false
end

rl.CloseWindow()

The GuiWindowBox function returns a number, but the examples don't take this into account.

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