November 30, 2020, 01:54:04 AM

Author Topic: [bmx] Identify Events by Bobysait [ 1+ years ago ]  (Read 619 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Identify Events by Bobysait [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Identify Events
Author : Bobysait
Posted : 1+ years ago

Description : You may want to know what kind of event is generated by your program, but printing EventId() for unknown events just show you a number ... like 515 or 1028, you just  still don't know what kind of event it refers

So, here is a small sdk to help you explain events


Code :
Code: BlitzMax
  1. ' TMap that register event Ids and there EVENT_XXXX const name + the tip associated in the "blitzmax Help"
  2.  
  3. Global EventNames:TMap=CreateMap()
  4. Global EventTips:TMap=CreateMap()
  5.  
  6. ' Easy way to register an event
  7. Function MapsInsert_(Key:Int,evname:String,tip:String)
  8.         MapInsert(EventNames,String(Key),evname)
  9.         MapInsert(EventTips,String(Key),tip)
  10. End Function
  11.  
  12. ' register all the standart events
  13. MapsInsert_(  257,"EVENT_APPSUSPEND", "Application suspended" )
  14. MapsInsert_(  258,"EVENT_APPRESUME", "Application resumed" )
  15. MapsInsert_(  259,"EVENT_APPTERMINATE", "Application wants To Terminate" )
  16. MapsInsert_(  513,"EVENT_KEYDOWN", "Key pressed. Event data Contains keycode" )
  17. MapsInsert_(  514,"EVENT_KEYUP", "Key released. Event data Contains keycode" )
  18. MapsInsert_(  515,"EVENT_KEYCHAR", "Key character. Event data contains unicode value" )
  19. MapsInsert_( 1025,"EVENT_MOUSEDOWN", "Mouse button pressed. Event data Contains mouse button code" )
  20. MapsInsert_( 1026,"EVENT_MOUSEUP", "Mouse button released. Event data Contains mouse button code" )
  21. MapsInsert_( 1027,"EVENT_MOUSEMOVE", "Mouse moved. Event X And Y contain mouse coordinates" )
  22. MapsInsert_( 1028,"EVENT_MOUSEWHEEL", "Mouse wheel spun. Event data Contains delta clicks" )
  23. MapsInsert_( 1029,"EVENT_MOUSEENTER", "Mouse entered gadget area" )
  24. MapsInsert_( 1030,"EVENT_MOUSELEAVE", "Mouse Left gadget area" )
  25. MapsInsert_( 2049,"EVENT_TIMERTICK", "Timer ticked. Event source Contains timer Object" )
  26. MapsInsert_( 4097,"EVENT_HOTKEYHIT", "Hot Key hit. Event data And mods Contains hotkey keycode And modifier" )
  27. MapsInsert_(32769,"EVENT_MENUACTION", "Menu has been selected" )
  28. MapsInsert_(16385,"EVENT_WINDOWMOVE", "Window has been moved" )
  29. MapsInsert_(16386,"EVENT_WINDOWSIZE", "Window has been resized" )
  30. MapsInsert_(16387,"EVENT_WINDOWCLOSE", "Window Close icon clicked" )
  31. MapsInsert_(16388,"EVENT_WINDOWACTIVATE", "Window activated" )
  32. MapsInsert_(16389,"EVENT_WINDOWACCEPT", "Drag And Drop operation was attempted" )
  33. MapsInsert_( 8193,"EVENT_GADGETACTION", "Gadget State has been updated" )
  34. MapsInsert_( 8194,"EVENT_GADGETPAINT", "A Canvas Gadget needs To be redrawn" )
  35. MapsInsert_( 8195,"EVENT_GADGETSELECT", "A TreeView Node has been selected" )
  36. MapsInsert_( 8196,"EVENT_GADGETMENU", "User has Right clicked a TreeView Node Or TextArea gadget" )
  37. MapsInsert_( 8197,"EVENT_GADGETOPEN", "A TreeView Node has been expanded" )
  38. MapsInsert_( 8198,"EVENT_GADGETCLOSE", "A TreeView Node has been collapsed" )
  39. MapsInsert_( 8199,"EVENT_GADGETDONE", "An HTMLView has completed loading a page" )
  40.  
  41.  
  42. ' and 2 function that return explicits events name
  43.  
  44. ' return the name ( the Integer const as a string ) for the id of the event
  45. Function EventName:String(evid:Int)
  46.         Return String(EventNames.ValueForKey(String(evid)))
  47. End Function
  48.  
  49. ' return the description for the id of the event
  50. Function EventHelp:String(evid:Int)
  51.         Return String(EventTips.ValueForKey(String(evid)))
  52. End Function


Comments :


Ked(Posted 1+ years ago)

 What's wrong with this?:
Code: [Select]
Local e:TEvent=WaitEvent()
Print e.ToString()



Bobysait(Posted 1+ years ago)

 sorry to answer so late, I didn't notice your post.There 's nothing wrong with Event.ToString().When I posted this stuff, I just didn't know ToString was available with Events. [/i]

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal