I have a large amount  of monkey patches to get into the mx emulation code
which I will try to get in earlier, but that realistically I might not get
to until September. iirc, I think there were some keyboard event related
improvements among them. Emulation already has the keyDown vs. keydown
variation handled. I think we already do similar for mouseDown vs mousedown
etc in UIBase?

A few notes:
Harbs added KeyboardEventConverterTest in 2017 which looks like it might
have something to do with native vs 'flash-like' event type conversions.
In flash api, I think all InteractiveObjects can have event listeners for
keyboard events, which includes Sprites and MovieClips etc, so pretty much
'all things' from a 'Flex' perspective.
But like Yishay says, for Keyboard events the browser defaults to either
top level (document or window, I can't remember exactly) or input controls
for keyboard event dispatchers. However, you can get them also from
elements like div if you set tabindex to zero (for example) on the div.


On Thu, Jul 13, 2023 at 8:23 AM Yishay Weiss <yishayj...@hotmail.com> wrote:

> What needs to be in UIBase is not exact science, but mouse events apply to
> nearly all controls whereas keyboard events are usually limited to
> textinputs and such, and even then you don't necessarily need to capture
> them. So I think there is reason to prefer mouse over keyboard. TextInput
> in Basic has the 'change' event meta-tag, so that covers some additional
> common scenarios.
>
> I agree that DispatchKeyboardEventBead forces a sort of awkward syntax in
> mxml. Maybe creating a similar bead that is also an IEventDispatcher would
> look nicer in code? Then I think you could do
> <Strand><beads><DispatcherBead
> keyboardEvent="handler()"/></beads></Strand>. Another option is creating
> MyTextInput that has [Event(name="keydown")] on top of "change".
>
>
> ________________________________
> From: Harbs <harbs.li...@gmail.com>
> Sent: Thursday, July 13, 2023 8:42 AM
> To: dev@royale.apache.org <dev@royale.apache.org>
> Subject: Re: UIBase has mouse events but not keyboard events?
>
> Also: with modern apps that might have touch events, keydown and keyup are
> less useful than they used to be. Handling all the input-related events by
> default is likely a bit much.
>
> > On Jul 13, 2023, at 8:40 AM, Harbs <harbs.li...@gmail.com> wrote:
> >
> > I don’t have any objections on principle, but there is something which
> might be a technical challenge:
> >
> > In swf it’s “keyDown” and “keyUp”, but in JS it’s “keydown” and “keyup”.
> I’m not sure how to handle that with metadata and MXML.
> >
> >> On Jul 13, 2023, at 1:20 AM, Josh Tynjala <joshtynj...@bowlerhat.dev>
> wrote:
> >>
> >> I'm trying to convert some Flex code to Royale. In particular, I'd like
> to
> >> add a keyDown listener to a component in MXML so I can listen to special
> >> keys like Esc, but there doesn't seem to be any [Event] metadata for
> >> keyboard events on UIBase. I see that there is [Event] metadata for
> mouse
> >> events, though.
> >>
> >> Maybe I've missed it, but there also doesn't even seem to be a bead that
> >> can somehow allow me to add a keyDown listener in MXML either. I found
> >> DispatchKeyboardEventBead, but it seems to dispatch the event on the
> >> strand, which would require me to manually call addEventListener() in
> AS3
> >> instead, which is pretty complicated because I would need to listen to
> some
> >> other event in MXML first, like initialize or whatever.
> >>
> >> Both mouse and keyboard feel to me like pretty fundamental forms of user
> >> input. With that in mind, if PAYG is the justification for not exposing
> >> keyboard events, I'm not sure how the same justification doesn't apply
> to
> >> mouse events. On the other hand, if it's something that actually should
> be
> >> exposed without beads, and it simply hasn't been a priority yet, then I
> >> hope someone can help me add it. I tried my best to figure out how
> Royale
> >> MouseEvents get converted from HTML/JS mouse events, to see if I could
> do
> >> something similar with keyboard events, but it wasn't clear to me where
> the
> >> lowest level listeners were being added for things like
> >> mousedown/mouseup/mousemove/etc.
> >>
> >> --
> >> Josh Tynjala
> >> Bowler Hat LLC <https://bowlerhat.dev>
> >
>
>

Reply via email to