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

Support for rendering and interaction on monitor #4

Closed
tizu69 opened this issue Aug 8, 2023 · 1 comment
Closed

Support for rendering and interaction on monitor #4

tizu69 opened this issue Aug 8, 2023 · 1 comment

Comments

@tizu69
Copy link
Contributor

tizu69 commented Aug 8, 2023

right now, the flow I use is

moni.clear()
prime.button(moni, ...)
parallel.waitForAny(prime.run, function()
  while true do
    -- event loop
  end
end)

this works, but interactions are on the computer, not the monitor (touch events, keyboard-only components don't make sense). if I get to it, I'll pr something tmr, otherwise take this quick sample I wrote in 5 minutes (take it with a grain of salt - there's probably something I forgor) - note this is only for buttons, but the general concept stays

function PrimeUI.button(win, x, y, text, action, fgColor, bgColor, clickedColor, periphName) -- periphName = string | nil
  -- ...
  if event == "mouse_click" and periphName == nil and button == 1 and clickX >= screenX and clickX < screenX + #text + 2 and clickY == screenY then
    -- ...
  elseif event == "monitor_touch" and periphName == button and clickX >= screenX and clickX < screenX + #text + 2 and clickY == screenY
    or event == "mouse_up" and button == 1 and buttonDown then -- buttonDown is false because the mouse_click event is blocked when clicked on the screen
    -- ..
  end
end

-----------

prime.button(monitorRight, 2, 4, string.char(25), function()
  -- ...
end, nil, nil, nil, "right")) -- this could probably be stripped down by using the win var, not sure
@tizu69
Copy link
Contributor Author

tizu69 commented Aug 8, 2023

additionally, primeui.clear should have a prop for the terminal to use

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