ui.Textbox.onChange
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลงทะเบียนการเรียกกลับที่จะเรียกใช้เมื่อข้อความในกล่องข้อความเปลี่ยนแปลง
โดยเฉพาะอย่างยิ่ง ระบบจะเรียกใช้ Callback เมื่อเกิดเหตุการณ์ต่อไปนี้
- ผู้ใช้พิมพ์ค่าใหม่ จากนั้นช่องข้อความจะสูญเสียโฟกัสหรือผู้ใช้กด Enter
- มีการตั้งค่าใหม่โดยใช้โปรแกรมด้วย set('value', newValue)
แสดงผลรหัสที่ส่งไปยัง unlisten() เพื่อยกเลิกการลงทะเบียนแฮนเดิลการเรียกกลับ
การใช้งาน | การคืนสินค้า |
---|
Textbox.onChange(callback) | สตริง |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ ui.textbox | ui.Textbox | อินสแตนซ์ ui.Textbox |
callback | ฟังก์ชัน | การเรียกกลับที่จะทริกเกอร์เมื่อข้อความเปลี่ยนแปลง โดยการเรียกกลับจะส่งข้อความที่อยู่ในกล่องข้อความและวิดเจ็ตกล่องข้อความในขณะนั้น |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eTriggers a function when the textbox content is modified, either by user input or programmatically.\u003c/p\u003e\n"],["\u003cp\u003eThe registered function receives the current text and the textbox widget as arguments.\u003c/p\u003e\n"],["\u003cp\u003eProvides a method to unregister the function using a unique ID returned during registration.\u003c/p\u003e\n"],["\u003cp\u003eText change is triggered by user input (typing followed by focus loss or pressing Enter), or by programmatically setting a new value.\u003c/p\u003e\n"]]],[],null,["# ui.Textbox.onChange\n\n\u003cbr /\u003e\n\nRegisters a callback that's called when text in the textbox changes.\n\n\u003cbr /\u003e\n\nIn particular, the callback is called when:\n\n- The user types a new value and then either the textbox loses focus or the user presses enter.\n\n- A new value is set programmatically with set('value', newValue).\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|------------------------------|---------|\n| Textbox.onChange`(callback)` | String |\n\n| Argument | Type | Details |\n|--------------------|------------|------------------------------------------------------------------------------------------------------------------------------|\n| this: `ui.textbox` | ui.Textbox | The ui.Textbox instance. |\n| `callback` | Function | The callback to fire when the text changes. The callback is passed the text currently in the textbox and the textbox widget. |"]]