ui.Button.onClick
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลงทะเบียนการเรียกกลับที่จะทริกเกอร์เมื่อมีการคลิกปุ่ม
แสดงผลรหัสที่ส่งไปยัง unlisten() เพื่อยกเลิกการลงทะเบียนแฮนเดิลการเรียกกลับ
การใช้งาน | การคืนสินค้า |
---|
Button.onClick(callback) | สตริง |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ ui.button | ui.Button | อินสแตนซ์ ui.Button |
callback | ฟังก์ชัน | Callback ที่จะเริ่มทำงานเมื่อมีการคลิกปุ่ม ระบบจะส่งวิดเจ็ตปุ่มไปยังฟังก์ชันเรียกกลับ |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eonClick\u003c/code\u003e method registers a callback function that executes when the button is clicked.\u003c/p\u003e\n"],["\u003cp\u003eIt returns a unique ID that can be used with \u003ccode\u003eunlisten()\u003c/code\u003e to remove the registered callback.\u003c/p\u003e\n"],["\u003cp\u003eThe callback function receives the button widget as an argument when triggered.\u003c/p\u003e\n"]]],["The `Button.onClick` method registers a callback function to be executed upon a button click. It accepts a function as an argument, which will be passed the button widget when triggered. The method returns a unique string ID, used to unregister the callback later via `unlisten()`. The function callback is associated with the specific `ui.Button` instance where `onClick` is used.\n"],null,["# ui.Button.onClick\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the button is clicked.\n\n\u003cbr /\u003e\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|----------------------------|---------|\n| Button.onClick`(callback)` | String |\n\n| Argument | Type | Details |\n|-------------------|-----------|--------------------------------------------------------------------------------------------|\n| this: `ui.button` | ui.Button | The ui.Button instance. |\n| `callback` | Function | The callback to fire when the button is clicked. The callback is passed the button widget. |"]]