osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

It is currently not possible to declare custom interfaces as "positional" or "non-positional" event handlers

Open Flutterish opened this issue 3 years ago • 6 comments
trafficstars

Currently, there is a closed set of interfaces, which when implemented mark the drawable as able to handle (non)positional input (in HandleInputCache). It is not possible to add your own. I propose, instead of this list, a root interface such as I(Non)PositionalInputHandler, which would simply be an empty marker interface which all the current interfaces would inherit. This will allow new, custom interfaces which rely upon positional or non-positional input queues to be handled without needing to override Handles(Non)PositionalInput of every drawable which uses them. My particular use case is, I was trying to add a FileDrop handler interface, but found I had to override HandlePositionalInput of every drawable which uses it.

Flutterish avatar May 03 '22 16:05 Flutterish

I don't see why not, personally, but am interested in other opinions because I'm not sure why it wasn't done like that all along (maybe some purposeful locking-down?)

bdach avatar May 03 '22 17:05 bdach

I think it sounds okay. But I'd also say that we need a proper item-drop pattern within o!f itself at some point (not sure if @Flutterish is interested in helping make that happen).

peppy avatar May 04 '22 02:05 peppy

If you both think this proposal is okay, should I make a pr or do you want to handle it yourself?


But I'd also say that we need a proper item-drop pattern within o!f itself at some point (not sure if @Flutterish is interested in helping make that happen).

If I'm honest, I'm not exactly sure how to do it properly. If you look at how I did it in o!f-designer and the file drop input manager and the base game, its a bit hacky and improper. The IWindow class has no standard file drop event (and there is no event for when its "hovering" with the dragged file either), and the input manager binds into the base game event (which probably should be a game host event) and then it also needs to check if there aren't other input managers that handle that event or otherwise they will be duplicated and I'm not sure how to solve that particular problem. I'm not sure I'm familiar enough with the o!f input system to do this in a proper manner.

Flutterish avatar May 04 '22 05:05 Flutterish

I'd still want @smoogipoo's opinion at least on this sort of change. So may be fine to open a PR but I wouldn't expect it to be merged this week.

As an aside:

and there is no event for when its "hovering" with the dragged file either

I recall that we wanted this for the game too, but SDL doesn't provide anything like this and so hands are a bit tied on that front unless a custom implementation is made for all platforms.

bdach avatar May 04 '22 05:05 bdach

I have a PoC IDropTarget implemented in a branch, so windows is covered in that regard.

Susko3 avatar May 04 '22 06:05 Susko3

A root interface is the first idea that came to my mind as well, so I'd be fine with that direction.

smoogipoo avatar May 05 '22 11:05 smoogipoo