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

העגלה ריקה

לפי הנחיות פיקוד העורף, עקב המצב הביטחוני, המחסן סגור.
נוכל לטפל בהזמנות שלכם לאחר שהמצב ירגע וינתן אישור להפעיל מקומות עבודה לא חיוניים.
יחד ננצח!

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


2024-11-25 11:08:26
פונקציית ()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.