This article mainly explains the view and viewgroup event transfer mechanism from the perspective of source code. The dispatchtouchevent method of viewgroup:
Private touchtarget firsttouchtarget;
Public Boolean dispatchtouchevent (motionevent eV ){
Perform Security check first to see if the current window is blocked.
If (Action = action_down ){
Clear the last touchtargets status to avoid the impact of action_up and action_cancel events on this method
Override ViewGroup and use ViewDragHelper to implement various drag-and-drop interactions,
1. If the previous SlideUpLayout control contains a list such as ListView or RecyclerView during use, the following problems may occur:
The xml file is as follows:
Ii. Cause Analysis: there is a problem with the event dispatch interception. Remember that in the previous article, the event interception was completely handled by ViewDragHe
) {// calculate the total pixel length var slpx = sl * this. stepLen; // calculate the length of the drag box var cenLen = this. option. scrollType = "V "? This. centerRect. offsetHeight: this. centerRect. offsetWidth; var dragBoxLen = cenLen-slpx; // if the calculated drag button is too short, re-calculate the step size to ensure that the button does not shorten if (dragBoxLen
/*** Mouse down event */doMouseDown: function (ev) {this. base (
the "New Connection" event, and then calls the event's handler handler function to process the event.
It has already been said that handler has been set to the Ngx_event_accept function, so call ngx_event_accept for actual processing.
The following is an analysis of the Ngx_event_accept method, whose flowchart looks like this:
Following the streamlined code, the number in the comment corresponds to the number of the previous figure:
void Ngx_event_accept (ngx_event_t *
added to the html page we need.
If this parameter is not added, an error is returned. Of course, if this parameter is not added, the current image display will not be affected, but the image rotation will be affected.
So far, the effect on the image is displayed, but it is now stiff, no animation, just static display.
3. Rotating and moving images
Ideas:
When the mouse is pressed and sliding, the overall wrap is also sliding, so you need to record the starting and ending positions of the mouse
Android Touch event distribution mechanism: androidtouch
Preface
The delivery of touch events in Android is worth studying. I have never seen you introduce a ListView slide function, so that ListView will not follow your finger's call to scroll. I also don't know why the Button has set onClick and onTouch. Who will first respond; maybe you will ask what is the difference between onTouch and onTouchEvent and how to use it? Everything here, as long as you understand the event distribution mechanis
);int height;int tempHeight=lp.height;if (tempHeight > 0) {height = MeasureSpec.makeMeasureSpec(tempHeight,MeasureSpec.EXACTLY);} else {height = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);}view.measure(width, height);}
5. if the hiding succeeds, we need to implement the specific functions below. pull-down refresh, release refresh, and refresh the three statuses. The status is changed through gestures. So here we need to implement onTouch, and of course there is OnScrollListener.
Y
of the distribution of any events. * because it returns false to the activity directly, the Action_down event is not processed. So subsequent events such as Action_down and action_up * are not eligible for processing, and are directly handled by the activity. * * * Test Two: * called in the Dispatchtouchevent () method of Myframelayout: Super.dispatchtouchevent (EV); * and returns return super.dispatchtouchevent (
the point moves, and moves the object to the new location. It correctly handles this situation: when the first finger drags the control to a position, then presses the second finger, and the second finger is on the same control. When the user lifts the first finger, the control does not run to the position of the second finger and the second finger can continue to drag the control.The ' active pointer ' is the one currently moving our object.private int mactivepointerid = invalid_pointer_id; @O
Now, let's move it to the body. We will introduce several function functions before getting started!
1. functions used to format events
CopyCode The Code is as follows: function getevent (){
// Compatible with both IE and FF
If (document. All) return window. event;
Func = getevent. Caller;
While (func! = NULL ){
VaR arg0 = func. Arguments [0];
If (arg0 ){
If (arg0.constructor = event | arg0.constructor = mouseevent)
| (Typeof (arg0) = "object" arg0.preventdefault arg0.stoppropagation )){
Retu
parameters, and event precedence is the intermediate level (CURRENT_BASE->NACTIVEQUEUES/2) of the current event_base. The definition of the event object is shown below:
struct Event {Tailq_entry (event) Ev_next;Tailq_entry (event) Ev_active_next;Tailq_entry (event) Ev_signal_next;Rb_entry (event) Ev_timeout_node;struct Event_base *ev_base;int ev_fd;Short ev_events;Short Ev_ncalls;Short *ev_pncalls; /* allows deletes in callback * *struct Timeval ev_timeout;int ev_pri; /* Smaller numbers are hi
Write a very simple time server as an example: when you connect up, the Server side provides you with a direct timeframe and then ends the connection. Event_init () represents the variable used by the initialization libevent. Event_set (ev, S, Ev_read | Ev_persist, Connection_accept, ev) puts s This File Description into the EV (the first parameter and the second
Now, let's move it to the body. We will introduce several function functions before getting started!1. functions used to format eventsCopy codeThe Code is as follows:Function getEvent (){// Compatible with both ie and ffIf (document. all) return window. event;Func = getEvent. caller;While (func! = Null ){Var arg0 = func. arguments [0];If (arg0 ){If (arg0.constructor = Event | arg0.constructor = MouseEvent)| (Typeof (arg0) = "object" arg0.preventDefault arg0.stopPropagation )){Return arg0;}}Fun
The event types in android include button events and screen Touch events. Touch events are the basic events of screen Touch events, so it is necessary to have a deep understanding of them.A simple screen Touch action triggers a series of Touch events: ACTION_DOWN-> ACTION_MOVE...-> ACTION_MOVE-> ACTION_UPWhen the screen contains a ViewGroup and the ViewGroup contains a sub-view, how does the android system handle Touch events? Is ViewGroup used to process Touch events or child views used to proc
If you constrain a div's draggable range to a specified element:Drag effect everyone may be familiar with, but usually the drag range is limited, through an example code to explain how to drag a div to a specified range of elements, code example is as follows:DOCTYPE HTML> HTML> Head> MetaCharSet= "Utf-8"> Metaname= "Author"content= "http://www.softwhy.com/" /> title>Ant Tribetitle> styletype= "Text/css">#box{width:400px;Height:300px;Background-color:Red;margin:0px Auto;position:relative;}#drag{
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.