Skip to content

Discussion - should IInputReceiverKeyboard be generic? #1880

@vchelaru

Description

@vchelaru

Currently IInputReceiverKeyboard has the following members:

    bool IsShiftDown { get; }
    bool IsCtrlDown { get; }
    bool IsAltDown { get; }
    string GetStringTyped();

The following is being added temporarily to help unify more raylib code:

    IEnumerable<int> KeysTyped { get; }

However, additional methods are needed for keys typed, repeat rate, etc. These could also use int but it would require a lot of casting, and would require implementors to handle creating conversion methods from their enum to int.

Instead, we could make this generic:

public interface IInputReceiverKeyboard
    <T> where T : struct, System.Enum

This would allow all Forms code to use IInputReceiverKeyboard directly.

Alternatively, everything could use KeyCombos and that code could internally cast to the right library, but that also makes the code more difficult to maintain across multiple platforms.

This change will likely require some changes to FlatRedBall, so need to investigate here.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions