Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SizeChanged event #326

Closed
johannesegger opened this issue Feb 9, 2019 · 5 comments
Closed

Add SizeChanged event #326

johannesegger opened this issue Feb 9, 2019 · 5 comments
Labels
t/enhancement New feature or request

Comments

@johannesegger
Copy link

johannesegger commented Feb 9, 2019

I would like to store the size of an AbsoluteLayout control within my model, because based on that I can tell whether some controls (i.e. players) within this layout are touching the border. Xamarin.Forms has VisualElement.SizeChanged, but in Fabulous I couldn't find something similar. The only thing I found was OnSizeAllocatedCallback which only works when attached to a ContentPage.

Would it be possible for you to enable SizeChanged events for ViewElements or how else could I store the size of a specific control within my Elmish model?

@TimLariviere
Copy link
Member

Thanks for reporting.
We will add SizeChanged and the other missing events from VisualElement.

@johannesegger
Copy link
Author

Awesome, thanks a lot for adding this so fast.

@johannesegger
Copy link
Author

Hm, not sure if this helps me a lot, though:

View.AbsoluteLayout(...)
|> sizeChanged (fun _ -> dispatch (SetSceneSize ???))

How do I get the size now from within the event handler? I neither get the sender nor do I get useful event args.

@TimLariviere
Copy link
Member

Ah. Xamarin.Forms does not send the new size...

SizeChanged?.Invoke(this, EventArgs.Empty);

As I would prefer not to pass the sender, I think we can create a new type SizeChangedEventArgs which will store the width and height of the control.
This will allow this kind of code:

View.AbsoluteLayout(...)
|> sizeChanged (fun args -> dispatch (SetSceneSize (args.Width, args.Height)))

@TimLariviere TimLariviere reopened this Feb 15, 2019
@johannesegger
Copy link
Author

Yeah, I would also prefer that, thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants