func_event_addhook.rst 985 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .. _func_event_addhook:
  2. =======
  3. AddHook
  4. =======
  5. AddHook -
  6. Description
  7. ===========
  8. .. code-block:: blitzmax
  9. AddHook( id,func:Object( id,data:Object,context:Object ),context:Object=Null,priority=0 )
  10. Add a hook function
  11. Add a hook function to be executed when #RunHooks is called with the specified hook @id.
  12. Parameters
  13. ==========
  14. Return Values
  15. =============
  16. A hook object that can be used with the #RemoveHook command.
  17. Examples
  18. ========
  19. .. code-block:: blitzmax
  20. 'This function will be automagically called every Flip
  21. Function MyHook:Object( id,data:Object,context:Object )
  22. Global count
  23. count:+1
  24. If count Mod 10=0 Print "Flips="+count
  25. End Function
  26. 'Add our hook to the system
  27. AddHook FlipHook,MyHook
  28. 'Some simple graphics
  29. Graphics 640,480,0
  30. While Not KeyHit( KEY_ESCAPE )
  31. Cls
  32. DrawText MouseX()+","+MouseY(),0,0
  33. Flip
  34. Wend
  35. See Also
  36. ========