The Partridge Family were neither partridges nor a family. Discuss.
-
BerlingSwe
- Posts: 13
- Joined: June 17th, 2017, 5:46 pm
- Location: Sweden
Post
by BerlingSwe » September 9th, 2017, 6:17 am
Hi. I am in the process of expanding the original chili framework to support GUI (menus, buttons etc)
But there is one small thing that has been bugging me for days and I have tried various different ways to solve it but none have worked.
Code: Select all
if (mouse.LeftIsPressed())
{
isClicked = !isClicked;
}
Basically I want the button to toggle every time it is clicked once, but if I hold down the left mouse button, the button toggles back and fourth many times quickly, which is not what i want. I want it to toggle once no matter how long you are holding the left mouse button for.
Any help appreciated, thanks!
-
ceofil
- Posts: 39
- Joined: April 13th, 2017, 8:35 pm
Post
by ceofil » September 9th, 2017, 9:48 am
-
Slidy
- Posts: 80
- Joined: September 9th, 2017, 1:19 pm
Post
by Slidy » September 9th, 2017, 1:22 pm
Not sure if that wiki page helped you, but my solution was to run it when mouse is depressed instead of pressed. Can be done by keeping track of bool.
e.g.
Code: Select all
if( wnd.mouse.LeftIsPressed() )
{
wasPressed = true;
}
else
{
if( wasPressed )
{
// do code
}
wasPressed = false;
}
-
BerlingSwe
- Posts: 13
- Joined: June 17th, 2017, 5:46 pm
- Location: Sweden
Post
by BerlingSwe » September 9th, 2017, 2:17 pm
Slidy wrote:Not sure if that wiki page helped you, but my solution was to run it when mouse is depressed instead of pressed. Can be done by keeping track of bool.
e.g.
Code: Select all
if( wnd.mouse.LeftIsPressed() )
{
wasPressed = true;
}
else
{
if( wasPressed )
{
// do code
}
wasPressed = false;
}
Thank you kind sir
-
albinopapa
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Post
by albinopapa » September 10th, 2017, 1:45 am
Just want to point out that the info on the wiki is a better fit for what you are trying to do.
Code: Select all
while( !wnd.mouse.IsEmpty() )
{
const auto e = wnd.mouse.Read();
if( e.GetType() == Mouse::Event::Type::LPress )
{
// Handle press event
}
else if( e.GetType() == Mouse::Event::Type::LRelease )
{
// Handle release event
}
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com