scenic icon indicating copy to clipboard operation
scenic copied to clipboard

New component events

Open GPrimola opened this issue 2 years ago • 7 comments

Description

This PR adds new events to the following built in components:

  • Scenic.Component.Button

    • {:btn_pressed, id} - sent when a button is pressed
    • {:btn_released, id} - sent after the button is released
  • Scenic.Component.Input.TextField

    • {:focus, id} - sent when a text field is "active", i.e., is ready to receive inputs
    • {:blur, id} - sent when a text field becomes "inactive", i.e., will not receive inputs
  • Scenic.Component.Input.Dropdown

    • {:dropdown_opened, id} - sent when the dropdown opens
    • {:dropdown_closed, id} - sent when the dropdown closes
    • {:dropdown_item_hover, id, item_id} - sent when and item is hovered

Motivation and Context

Those new events are very helpful in certain scenarios.

Types of changes

  • [ ] Bug fix (a non-breaking change which fixes an issue)
  • [x] New feature (a non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Improvement/refactoring (non-breaking change that doesn't add any feature but make things better)

Checklist

  • [x] Check other PRs and make sure that the changes are not done yet.
  • [x] The PR title is no longer than 64 characters.

GPrimola avatar Oct 13 '22 14:10 GPrimola

Would you consider :focus instead of :focus_in and :blur instead of :focus_out?

crertel avatar Oct 15 '22 18:10 crertel

Also, for the over events, how do you feel about also perhaps sending a cursor position?

(Great work, btw!)

crertel avatar Oct 15 '22 18:10 crertel

Hey @crertel sorry for the long delay to reply you and thanks for your suggestions!

Sure, :focus and :blur are totally fine too, I'll push this change.

About sending the cursor position on the :hover event, I'm not sure. Could you give me any use case for that? Would you imagine this cursor position being local cursor position (relative to the component or to the item box) or global position (the position on the viewport)?

My thoughts about this is should anyone need the cursor position they should request the :cursor_position input and combine the event's data using assigns on the scene. But this may be because I don't have any use case in mind.

GPrimola avatar Oct 28 '22 19:10 GPrimola

I'm pretty flexible on this...I'm thinking that it might be helpful for cases where we want to handle something local to the component (say, updating a gradient or some other UI effect) and doing it elsewhere could be clunky. Not super wed to it though--what do you think? :)

crertel avatar Oct 30 '22 22:10 crertel

@crertel I tried to run mix test locally to see what's going on, and it succeeded, maybe this is a flaky test?

Screenshot 2023-08-04 at 11 18 25

GPrimola avatar Aug 04 '23 09:08 GPrimola

Hey @crertel would you mind to run the CI/build action again? I've checked and it seems all good:

Screenshot 2023-08-08 at 10 06 07

Many thanks and sorry for the pings 🙂

GPrimola avatar Aug 08 '23 08:08 GPrimola

Looks green! Great work, I bet folks will get some good use out of these. Very sorry for the delay on our side. Lemme page @axelson in too, but I'm liking this.

crertel avatar Feb 15 '24 03:02 crertel