Fusion / libui.cr

Crystal-lang bindings for libui
MIT License
176 stars 17 forks source link

UI::Area available? #9

Closed kojix2 closed 3 years ago

kojix2 commented 6 years ago

I compiled the code below.

ah = UI::AreaHandler.new
area = UI.new_area pointerof(ah)

Then I got the error message "undefined method 'new' for UI::AreaHandler:Class" It may be because the UI::AreaHandler struct is not fully defined. I thought for a moment, but C pointers are difficult for me. I want to draw figures. Is there a good way to do it?

refi64 commented 6 years ago

You would have to properly define the UI::AreaHandler struct, and then do:

ah = uninitialized UI::AreaHandler
area = UI.new_area pointerof(ah)

However, if you try this code now without a proper UI::AreaHandler declaration, then it's going to crash.

I think it would look like this for starters:

struct AreaHandler
  draw : Void*
  mouse_event : Void*
  mouse_crossed : Void*
  drag_broken : Void*
  key_event : Void*
end
kojix2 commented 3 years ago

Thank you!