TextEditor_gd (GM_HANDLEINPUT or GM_EXTENT)

2 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 9 hours 18 min ago
Joined: 2013-05-30 00:53
TextEditor_gd (GM_HANDLEINPUT or GM_EXTENT)

Hi, is it possible to add a new keybinding to texteditor_gd? (how to add to GM_HANDLEINPUT or GM_EXTENT)

In InfoWB I want to add into tooltypes (texteditor) gadget, that when you SHIFT+Doubleclick an entry it gets enabled/disabled '(' ')', like RAWBInfo does.

TiA

jabirulo
jabirulo's picture
Offline
Last seen: 9 hours 18 min ago
Joined: 2013-05-30 00:53
Re: TextEditor_gd (GM_HANDLEINPUT or GM_EXTENT)

Hi, think I got it :-)
Just need to "make" a class "child" of TextEditorClass using a hook/dispatch:

  1. Class *myTEClass;
  2. struct myTEClassData {
  3. uint32 toggletooltype;
  4. };
  5. ...
  6. if( (myTEClass=IINTUITION MakeClass(NULL, NULL, TextEditorClass, sizeof(struct myTEClassData), 0)) )
  7. {
  8. myTEClass->cl_Dispatcher.h_Entry = (HOOKFUNC)myTEClassDispatcher;
  9. //myTEClass->cl_Dispatcher.h_Data = NULL;
  10. //myTEClass->cl_UserData = 0;
  11. //IINTUITION AddClass(myTEClass);
  12. }

and in the GUI creation change:

  1. LAYOUT_AddChild, node->infGads[INFO_TOOLTYPES] = IINTUITION NewObject(TextEditorClass, NULL,

to:

  1. LAYOUT_AddChild, node->infGads[INFO_TOOLTYPES] = IINTUITION NewObject(myTEClass, NULL,

and myTEClass "methods":

  1. static uint32 myTEClass_GM_HandleInput(Class *cl, Object *obj, struct gpInput *msg)
  2. {
  3. struct myTEClassData *data = INST_DATA(cl, obj);
  4. struct Gadget *gad = (struct Gadget *)obj;
  5. uint32 retval;
  6. //DB("myTEClass_GM_HandleInput()\n");
  7.  
  8. if( (gad->Flags & GFLG_SELECTED) == 0 )
  9. {
  10. return(GMR_NOREUSE);
  11. }
  12.  
  13. switch(msg->gpi_IEvent->ie_Class)
  14. {
  15. case IECLASS_RAWKEY:
  16. {
  17. //DB(" IECLASS_RAWKEY:0x%0lx\n",msg->gpi_IEvent->ie_Code);
  18. switch(msg->gpi_IEvent->ie_Code)
  19. {
  20. case RAWKEY_RSHIFT:
  21. case RAWKEY_LSHIFT:
  22. //DB(" SHIFT pressed\n");
  23. data->toggletooltype = 1;
  24. retval = GMR_MEACTIVE;
  25. break;
  26. default:
  27. data->toggletooltype = 0;
  28. retval = IINTUITION IDoSuperMethodA(cl, obj, (APTR)msg);
  29. break;
  30. }
  31.  
  32. break;
  33. }
  34.  
  35. case IECLASS_RAWMOUSE:
  36. {
  37. //DB(" IECLASS_RAWMOUSE:0x%0lx\n",msg->gpi_IEvent->ie_Code);
  38. switch(msg->gpi_IEvent->ie_Code)
  39. {
  40. case SELECTDOWN:
  41. {
  42. //DB(" LMB pressed (%ld)\n",data->toggletooltype);
  43. if(data->toggletooltype)
  44. {
  45. uint32 lin;
  46. //ToogleTooltypeLine();
  47. //IINTUITION GetAttr(GA_TEXTEDITOR_Prop_Entries, obj, &lin);
  48. STRPTR txt = (STRPTR)IINTUITION IDoMethod(obj, GM_TEXTEDITOR_ExportText, NULL);
  49. DB(" txt='%s'\n",txt);
  50. IINTUITION GetAttr(GA_TEXTEDITOR_CursorY, obj, &lin);
  51. DB(" cursor=%ld\n",lin);
  52. }
  53. }
  54. break;
  55. }
  56.  
  57. retval = IINTUITION IDoSuperMethodA(cl, obj, (APTR)msg);
  58. break;
  59. }
  60.  
  61. default:
  62. {
  63. retval = IINTUITION IDoSuperMethodA(cl, obj, (APTR)msg);
  64. break;
  65. }
  66. }
  67.  
  68. return(retval);
  69. }
  70.  
  71. static uint32 myTEClassDispatcher(Class *cl, Object *obj, Msg msg)
  72. {
  73. //struct myTEClassData *data = INST_DATA(cl, obj);
  74. uint32 ret;
  75.  
  76. /*if(msg->MethodID == OM_NEW)
  77. {
  78. return( myTEClass_OM_New(cl, obj, (APTR)msg) );
  79. }
  80. else if(msg->MethodID == OM_DISPOSE)
  81. {
  82. return( myTEClass_OM_Dispose(cl, obj, (APTR)msg) );
  83. }
  84. else
  85. {*/
  86. //IEXEC ObtainSemaphore(&data->Semaphore);
  87.  
  88. switch(msg->MethodID)
  89. {
  90. /* BOOPSI methods */
  91. case GM_HANDLEINPUT:
  92. ret = myTEClass_GM_HandleInput(cl, obj, (APTR)msg);
  93. break;
  94. default:
  95. ret = IINTUITION IDoSuperMethodA(cl, obj, (APTR)msg);
  96. break;
  97. }
  98.  
  99. //IEXEC ReleaseSemaphore(&data->Semaphore);
  100.  
  101. return(ret);
  102. // }
  103. }
  104. /* DISPATCHER TextEditor */
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
Log in or register to post comments