This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
elexx's profile picture

Touchscreen Api

Started by elexx, 19 March 2013 - 03:43 AM
elexx #1
Posted 19 March 2013 - 04:43 AM
About
This API provides easy access to a term, whether it is an advanced computers screen or an advanced monitor or 5 advanced monitors attached to just one computer.

This package provides …
  • … a button creation function, where a button is basically a rectangle with some text in it. A Button can be parameterized: size, position, horizontal/vertical or no text at all, callback function if it gets clicked.
  • … a text and label creation function. Clicking a label will run the callback of an associated button.
  • … a wrapper for a term with a built in coordinate to element mapping, which can be used to map mouse_click or monitor_touch events to elements (e.g. buttons, created by the buttonAPI). The cool thing about this is, it can even handle elements which are outside of the term, by introducing a "backpanel" with infinite size. This elements can be drawn on the term (= are sticky) or on the backpanel (= none sticky). The backpanel can then be moved around and used to have e.g. multiple pages of buttons, while it's possible at the same time to have some buttons not moving, ever present (e.g. a "next page" - button).
  • … a really basic event dispatcher which replaces the ever-present "while true do os.pullEvent …" - loop
  • … a ever growing bunch of demos :)/>
Code
The code and additional documentations are available on GitHub. - I appreciate fork/open issues/open pull requests!

Examples
Examples are available on GitHub - demos too.
Of course there are docs available for each demo: GitHub - docs

If you are interessted in using it, have a look at the docs/GetStarted.md

Screenshots
The idea of this API is to provide easer access to common problems according touch and click events in ComputerCraft. It doesn't have any kind of gui or look&feel on it's own, so it's hard to provide amazing screenshots. Nevertheless I captured the screens of the demo programs: imgur.com/a/Ucv8Y

Installer
The installer can be downloaded from pastebin
pastebin get cXYAjesQ installer
pastebin.com/cXYAjesQ
It will ask you what packages you want to download (currently api and demos) and it will not override any files unless you run "installer update".
Edited on 17 October 2013 - 06:26 AM
Herû #2
Posted 19 March 2013 - 05:03 AM
I like what I see, will maybe test it.
elexx #3
Posted 12 October 2013 - 05:09 AM
updated - added a lot of cool new stuff, check the links in my first post
M4sh3dP0t4t03 #4
Posted 12 October 2013 - 12:37 PM
Please add screenshots.
elexx #5
Posted 13 October 2013 - 12:40 PM
Please add screenshots.
Screenshots added. But as I mentioned above, this API is only supposed to provide a bunch of helpers to make your life easier with click and touch events and the dispatching of those to functions. So it doesn't have any built in gui or something to showcase.
elexx #6
Posted 14 October 2013 - 08:24 AM
updated - new api method "addFilteredHandler" in eventDispatcherAPI and new docs an demos! :)/>
elexx #7
Posted 16 October 2013 - 07:34 AM
update - new elements "textbox" and "label" - and of course another demo and screenshot to showcase them!
elexx #8
Posted 17 October 2013 - 03:15 AM
update - added installer - just run "pastebin get cXYAjesQ installer" and "installer" to download all necessary files. or run "installer update" to update from an older version!