|
Post by indefatigable on Sept 15, 2014 18:07:36 GMT
Hi, I'm just looking over your tutorials and i'm wondering if ness engine supports gui applications with mouse support?
Thanks!
|
|
|
Post by Admin on Sept 17, 2014 8:30:09 GMT
hello indefatigableSep, ness-engine has no built-in gui system (you can implement one over ness-engine or use 3'th party system), but it does have a basic mouse utility. for example: Ness::Utils::EventsPoller EventsPoller; Ness::Utils::Mouse mouse; Ness::Utils::ApplicationEvents app; EventsPoller.add_handler(mouse); EventsPoller.add_handler(app); while( !app.got_quit() ) { // handle events EventsPoller.poll_events(); int x = mouse.position().x; int y = mouse.position().y; .... } full example here (tilemap editor)
|
|
|
Post by Sylentdeath on Jan 12, 2015 15:42:50 GMT
Does it possible to use a mouse.is_up() to ?
|
|
|
Post by Admin on Jan 13, 2015 0:19:45 GMT
!mouse.is_down(...) But a more serious answer: making functions for negative bools are usually useless and messy. For example if I make is_up() which is the same as !is_down(), then why not making is_invisible() (!is_visible()), is_dynamic() (!is_static()), and basically alias for every negative function that return a bool? This will very quickly pollute the apis and make it harder to find the functions you need.getters should not be redundant.
|
|
|
Post by Sylentdeath on Jan 13, 2015 16:13:07 GMT
Sry,
I think i was tired yesterday and i didn't make the good question so i will explain better the problem :
In key control management there functions for the gesture we could to with a key. Is pressed wich trigger when a key is hit. Key_down wich trigger when a key id pressed, and key_up which one trigger when a key is released. The gesture of realeasing the key is ofently called key_up. So when a asked for a is_up i confused myself and i asked for a negative of down state whicj i agree is a stupid question :-)
This is not an impossible probleme to resolve but i was during ly developpement with the probleme of a mouse down action that trigger 2 action :
Imagine an interruptor who can light on and light off. if light is on light off and if the light is off it make it on.
If i use the gesture of mouse_down as trigger : the light will blink because it will trigger permantly.
That why a asked id there implemented a trigger for releasing button. That make our clic action could only be triggred one with a gesture.
This problem can be resolved by many ways, but just want to know if the engine have a native way to hold it
|
|
|
Post by Sylentdeath on Jan 13, 2015 16:17:02 GMT
Ha for people who is interested :
i just add a boolean to save state, this wil make something like this :
bool mousestate = false; if (mouse.is_down(Ness::Utils::MOUSE_LEFT)) { if(!mousestate ) { // DO HERE WANT YOU WANT mousestate = true; } } else { mousestate = false; }
|
|
|
Post by Admin on Jan 13, 2015 18:24:46 GMT
ahh now you make a lot of sense its a good feature request. I will think of a way to solve this nicely and add this to next version. perhaps a set of was_pressed(), was_released() or was_clicked() that means in the current frame or something like that. (I want to keep the mouse and keyboard handlers without events, to keep their API simple and easy to use out of the main loop). meanwhile your patch seems to be suitable, in next version you will get a proper solution. thanks!
|
|
|
Post by Admin on Jan 14, 2015 22:26:05 GMT
|
|