func_maxgui_text fields_createtextfield.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .. _func_maxgui_text fields_createtextfield:
  2. ===============
  3. CreateTextField
  4. ===============
  5. CreateTextField -
  6. Description
  7. ===========
  8. .. code-block:: blitzmax
  9. CreateTextField:TGadget(x,y,w,h,group:TGadget,style=0)
  10. Create a TextField gadget.
  11. A TextField is a single line text entry gadget and currently has only one style flag:
  12. [ @Flags | @Meaning
  13. * TEXTFIELD_PASSWORD | Masks characters being typed as a string as asterisks.
  14. ]
  15. Irrespective of the flag used, the TextField gadget will emit the following event(s):
  16. [ @{Event ID} | @Description
  17. * EVENT_GADGETACTION | The user has edited the text in the TextField.
  18. ]
  19. It is also possible to validate any typed input before it reaches the TextArea using
  20. the #SetGadgetFilter command.
  21. See Also: #GadgetText, #SetGadgetText, #SetGadgetFilter.
  22. Parameters
  23. ==========
  24. Return Values
  25. =============
  26. Nothing.
  27. Examples
  28. ========
  29. .. code-block:: blitzmax
  30. ' createtextfield.bmx
  31. Import MaxGui.Drivers
  32. Strict
  33. Local window:TGadget
  34. Local textfield:TGadget
  35. Local button:TGadget
  36. window=CreateWindow("My Window",30,20,320,200)
  37. textfield=CreateTextField(4,4,120,22,window)
  38. SetGadgetText( textfield,"A textfield gadget" )
  39. ' we need an OK button to catch return key
  40. button=CreateButton("OK",130,4,80,24,window,BUTTON_OK)
  41. ActivateGadget textfield
  42. While WaitEvent()
  43. Print CurrentEvent.ToString()
  44. Select EventID()
  45. Case EVENT_GADGETACTION
  46. Select EventSource()
  47. Case textfield
  48. Print "textfield updated"
  49. Case button
  50. Print "return key / OK button pressed"
  51. End Select
  52. Case EVENT_WINDOWCLOSE
  53. End
  54. End Select
  55. Wend
  56. See Also
  57. ========