COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 08-04-2016, 04:26 PM   #1
maleako
Human being with feelings
 
Join Date: Jul 2013
Posts: 34
Default A control which supports being "Held Down"?

Does anyone have an example of a control they can post which supports being held down? For example, when pressed, it calls A(), but when held down for 2 seconds, calls B()?

The logical problem I am running into, is how to detect this without "OnMouseUp" being called, or the use of extra threads. Any pointers?

Last edited by maleako; 08-04-2016 at 04:39 PM.
maleako is offline   Reply With Quote
Old 08-04-2016, 05:26 PM   #2
snooks
Banned
 
Join Date: Sep 2015
Posts: 1,650
Default

This works, but does a bunch of unnecessary redrawing...
Code:
void OnMouseDown(int x, int y, IMouseMod* pMod)
{
   counter = 0;
   SetDirty(); // need this to start the Redraw cycle in Draw
}

void OnMouseUp(int x, int y, IMouseMod* pMod)
{
   counter = -1;
}

bool Draw(IGraphics* pGraphics)
{
   if (counter > -1)
   {
      ++counter;
      if (counter >= 100) // 2 * FPS(?)
      {
         LongPress();
         counter = -1;
      }
      else {
         Redraw();
      }
   }

   .......
}
snooks is offline   Reply With Quote
Old 08-04-2016, 08:48 PM   #3
maleako
Human being with feelings
 
Join Date: Jul 2013
Posts: 34
Default

Good idea! Thanks, It works
maleako is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.