Event-driven mechanism is widely used in embedded systems, similar to the interrupt mechanism, when an event arrives (such as a key, data arrives), the system responds to and processes the event. With respect to the polling mechanism, the event mechanism has the advantage of being a star, with low power consumption (the system is in hibernation and is awakened when an event arrives) and MCU utilization is high.Contiki the event mechanism into the protothreads mechanism, where each event binds to
based on the waiting conditions: if there are still read and write requests waiting, it is not triggered; if only the Read Request is waiting, then, it is triggered again so that other read requests can enter. over and over again, I decided to adopt manual events. After all, the number of read locks is much larger than the number of write locks (this is also a common scenario for read/write locks) faster (no need to wait for multiple events ).
Appendix 1-C ++ code
# Define RWLOCK_IDLE 0/* idle
to a new location. It correctly handles this situation: when the first finger dragged the control to a position, then pressed the second finger, and the second finger and the same control. When the user raises the first finger, the control does not run to 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;@Overridepublic boolean onTouchEvent(MotionEvent
Use javascript to obtain the cursor position on the page and the object that triggers the event. use javascript to obtain the cursor position:
The Code is as follows:
Function mousePosition (ev ){If (ev. pageX | ev. pageY ){Return {X: ev. pageX,Y: ev. pageY};}Return {X:
This article introduces how to use JS to obtain mouse coordinates. If you need it, refer to it.
The Code is as follows:
Var restrictX;Var restrictY;Var tip;// Mouse coordinatesFunction mousePosition (ev ){Return {X: ev. clientX + document.doc umentElement. scrollLeft-document.doc umentElement. clientLeft,Y: ev. clientY + document.doc umentElement. scrollTop-doc
Native javascript compatibility: currentStyle, scrollTop, event, and bound event IE binding events are attachEventdetachEvent compatibility test instances. If you are interested, refer to section 1. get the width, border color and other css (not line) in the style table is mainly IE6-7 support currentStyle, standard browser support getComputedStyle;
Instance: encapsulation Function
The Code is as follows:
Function getStyle (obj, name ){If (obj. currentStyle ){Return obj. currentStyle [name];
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2444
Question:
Yes N Students, including M People know each other. Each person can be assigned a room and asked if they can N The students are divided into two parts. The students in each part do not know each other, but the students in the two parts do not know each other. If it can be divided into two parts, the maximum number of rooms is calculated; otherwise, the output is No .
Analysis:
First, determine whether i
Use JavaScript to get the mouse position:
CopyCode The Code is as follows: function mouseposition (EV ){
If (EV. pagex | eV. Pagey ){
Return {
X: eV. pagex,
Y: eV. Pagey};}Return {X: eV. clientx + document. Body. scrollleft-d
"){
Public void run (){
// Call in a loop: readevent (EV );...Send = preprocessevent (Di, Ev );// The preprocessevent function of the keyq class is actually called....Int keycode = rotatekeycodelocked (EV. keycode );Int [] map = mkeyrotationmap;
For (INT I = 0; I
If (MAP = keycode)
Return map [I + 1];
}//Addlocked (Di, curtime,
source. Ie: window. event. under the srcElement standard: event.tar getnodeName: locate the Tag Name of the element */oUl. onmouseover = function (ev) {var ev = ev | window. event; var target = ev.tar get | ev. srcElement; // alert (target. innerHTML); if (target. nodeName. toLowerCase () = "li") {target. style. backg
1. Get the width, border color and other css (not line) in the style table is mainly IE6-7 support currentStyle, standard browser support getComputedStyle;
Instance: encapsulation FunctionCopy codeThe Code is as follows: function getStyle (obj, name ){If (obj. currentStyle ){Return obj. currentStyle [name];}Else {Return getComputedStyle (obj, false) [name];}}
Call: getStyle ('color ');
2. Get the scroll distanceDocument. body. scrollTop for standard browsersDocument.doc umentElement. scrollTop
1. Get the width, border color and other css (not line) in the style table is mainly IE6-7 support currentStyle, standard browser support getComputedStyle;Instance: encapsulation FunctionCopy codeThe Code is as follows:Function getStyle (obj, name ){If (obj. currentStyle ){Return obj. currentStyle [name];}Else {Return getComputedStyle (obj, false) [name];}} Call: getStyle ('color ');2. Get the scroll distanceDocument. body. scrollTop for standard browsersDocument.doc umentElement. scrollTop appl
indicates that the return type of the method is void.Click the non-MyButton area and the results are as follows:Click on the MyButton area and the results are as follows:With these two results we can find that the event is activity->viewgroup->view from the top down.However, there is a non-correspondence between the two results, that is, the first result of the Mylayout Onintercepttouchevent method is not executed when lifting, and the second result is executed. This is because the Dispatchtouc
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.