Home > Net >  C # how to implement a long press on the screen pop up a prompt box
C # how to implement a long press on the screen pop up a prompt box

Time:10-03

Currently envisaged is in the screen long after a few seconds (if is five seconds), you can bring up a prompt dialog box, and then perform other operations.
Could you tell me the how to implement?

CodePudding user response:

Professional point, what is changan screen, direct finger on the screen? No device support you give how many money can't solve,
So running a description of your problem, what circumstance, what operation equipment, what function,

CodePudding user response:

Emmm, refers to the fingers long press on the screen, the device is similar to a bank to do card operation of that kind of touch screen machine, equipment support;
Is if we have a bank can touch screen, I want to realize the function of is, when I was in the machine main interface, long press the screen any place (except for the click will realize the jump function area), or a certain area to set the number of seconds, the screen will pop up a prompt box, how should do excuse me such implementation; Describe the unprofessional, trouble the great spirit guide,

CodePudding user response:

Use the timer, the general idea is that in the event of your trigger TouchDown execution DeepTouch () to monitor whether long TouchUp events in accordance with the DisposeTouch ()
 
///& lt; Summary>
///long press processing, start the time
///& lt;/summary>
Private void DeepTouch ()
{
_timer=new Timer ();//monitor whether long press
_nDeepTouch=0;
_timer. Interval=1000;
_timer. Elapsed +=new ElapsedEventHandler (timer_Elapsed);//arrival time when executing events;
_timer. Enabled=true;
_timer. Start ();
}

///& lt; Summary>
///beginning on time long time
///& lt;/summary>
///& lt; Param name="sender" & gt;
///& lt; Param name="e" & gt;
Private void timer_Elapsed (object sender, ElapsedEventArgs e)
{
If (_nDeepTouch & gt;=5)//5 s to multi-select
{
MessageBox. Show (" long press time is greater than 5 s!" )
}
The else _nDeepTouch + +;
}

///& lt; Summary>
///mouse/touch release processing
///& lt;/summary>
Private void DisposeTouch ()
{
This. The Dispatcher. Invoke (new Action (delegate//another thread access line SPC a
{
_timer. Stop ();
_nDeepTouch=0;
_timer. Enabled=false;
}));
}

CodePudding user response:

MouseDown, MouseUp

CodePudding user response:

https://blog.csdn.net/youyomei/article/details/79753619 USES a delegated implementation

CodePudding user response:

refer to the second floor hzxcaq response:
emmm, refers to the fingers long press on the screen, the device is similar to a bank to do card operation of that kind of touch screen machine, equipment support;
Is if we have a bank can touch screen, I want to realize the function of is, when I was in the machine main interface, long press the screen any place (except for the click will realize the jump function area), or a certain area to set the number of seconds, the screen will pop up a prompt box, how should do excuse me such implementation; Describe the unprofessional, trouble the great spirit guide,

Listening to the left key press and raise events, press the timer after startup, after the specified time to activate the actual event, insufficient time to lift the timer shut, reset the timer
  •  Tags:  
  • C#
  • Related