facebook pixel מדריך: פירוט שפת תכנות - עכבר - ()Mouse.isPressed - www.4project.co.il
Main logo www.4project.co.il
כל הרכיבים לפרוייקט שלכם
עגלת קניות

העגלה ריקה

לקוחות נכבדים, אלה שעות הפעילות של המחסן במהלך פסח 2024:
ערב חג וחג ראשון (22-23/04) - המחסן סגור
חול המועד (24-25/04) - המחסן יפעל בין 8:00 עד 15:00
ערב חג וחג שני (28-29/04) - המחסן סגור
נחזור לפעילות רגילה ביום שלישי 30/04
חג שמח!

פירוט שפת תכנות - עכבר - ()Mouse.isPressed


2022-06-14 09:27:55
פונקציית ()Mouse.isPressed בודקת את מצב הלחיצה על כפתורי העכבר שבוצעו ע"י פונקציה ()Mouse.press.

קריאה לפונקציה ()Mouse.isPressed ללא פרמטרים תחשב כבדיקה של הכפתור השמאלי של העכבר.


תחביר

קוד: בחר הכל
Mouse.isPressed();
Mouse.isPressed(button);

פרמטרים:
button - מציין איזה כפתור לבדוק. יכול להיות אחד מהקבועים הבאים:
  • MOUSE_LEFT - כפתור השמאלי - ברירת המחדל כשהפונקציה נקראת ללא ציון הכפתור
  • MOUSE_RIGHT - כפתור ימני
  • MOUSE_MIDDLE - כפתור אמצעי

הפונקציה מחזירה ערך boolean המציין האם הכפתור לחוץ או לא.


דוגמה

קוד: בחר הכל
void setup(){
  //The switch that will initiate the Mouse press
  pinMode(2,INPUT);
  //The switch that will terminate the Mouse press
  pinMode(3,INPUT);
  //Start serial communication with the computer
  Serial1.begin(9600);
  //initiate the Mouse library
  Mouse.begin();
}

void loop(){
  //a variable for checking the button's state
  int mouseState=0;
  //if the switch attached to pin 2 is closed, press and hold the left mouse button and save the state in a variable
  if(digitalRead(2) == HIGH){
    Mouse.press();
    mouseState=Mouse.isPressed();
  }
  //if the switch attached to pin 3 is closed, release the left mouse button and save the state in a variable
  if(digitalRead(3) == HIGH){
    Mouse.release();
    mouseState=Mouse.isPressed();
  }
  //print out the current mouse button state
  Serial1.println(mouseState);
  delay(10);
}



ראו גם:

()Mouse.begin
()Mouse.click
()Mouse.end
()Mouse.move
()Mouse.press
()Mouse.release

מחלקות Mouse ו-Keyboard
פירוט שפת תכנות לסביבת Arduino


עמוד זה הוא תרגום של ()Mouse.isPressed לפי רישיון Creative Commons Attribution-ShareAlike 3.0.