GUITextField.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. public sealed class GUITextField : GUIElement
  7. {
  8. public delegate void OnChangedDelegate(String newValue);
  9. public event OnChangedDelegate OnChanged;
  10. public String Value
  11. {
  12. get
  13. {
  14. String value;
  15. Internal_GetValue(mCachedPtr, out value);
  16. return value;
  17. }
  18. set { Internal_SetValue(mCachedPtr, value); }
  19. }
  20. public GUITextField(GUIContent title, int titleWidth = 100, bool multiline = false, string style = "", params GUIOption[] options)
  21. {
  22. Internal_CreateInstance(this, multiline, title, titleWidth, style, options, true);
  23. }
  24. public GUITextField(bool multiline = false, string style = "", params GUIOption[] options)
  25. {
  26. Internal_CreateInstance(this, multiline, null, 0, style, options, false);
  27. }
  28. public bool HasInputFocus()
  29. {
  30. bool value;
  31. Internal_HasInputFocus(mCachedPtr, out value);
  32. return value;
  33. }
  34. private void DoOnChanged(String newValue)
  35. {
  36. if (OnChanged != null)
  37. OnChanged(newValue);
  38. }
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. private static extern void Internal_CreateInstance(GUITextField instance, bool multiline, GUIContent title, int titleWidth,
  41. string style, GUIOption[] options, bool withTitle);
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. private static extern void Internal_GetValue(IntPtr nativeInstance, out String value);
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern void Internal_SetValue(IntPtr nativeInstance, String value);
  46. [MethodImpl(MethodImplOptions.InternalCall)]
  47. private static extern void Internal_HasInputFocus(IntPtr nativeInstance, out bool value);
  48. }
  49. }