Advertisement
Dr_Davenstein

Simple callback example...

Jun 19th, 2021
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include "fbgfx.bi"
  2.  
  3. type gui_thing
  4.  
  5. dim onClick as function() as integer
  6.  
  7. end type
  8.  
  9.  
  10.  
  11. declare function userClick() as integer
  12.  
  13.  
  14. screenres 640,480,32
  15.  
  16. dim as gui_thing test
  17.  
  18. 'set the callback function to the one we wrote, instead of the one contained in the type
  19. test.onClick = @userClick()
  20.  
  21. dim as integer x, y, button
  22.  
  23.  
  24. do
  25.  
  26. getmouse(x,y,,button)
  27.  
  28. if button and 1 then
  29.  
  30. print test.onClick()
  31.  
  32. end if
  33.  
  34. sleep 3,1
  35.  
  36. loop until multikey(FB.SC_ESCAPE)
  37.  
  38.  
  39.  
  40.  
  41.  
  42. function userClick() as integer
  43.  
  44. static as integer value
  45.  
  46. value+=1
  47.  
  48. return value
  49.  
  50. end function
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement