Skip to content

Make press hold and enabled togglable #303

@Folcon

Description

@Folcon

Hey @tonsky

I've been using HumbleUI to build a game and I just finished wiring up camera panning and realised that kPressAndHoldEnabled is on by default

kPressAndHoldEnabled = nullptr == [userDefaults objectForKey:@"ApplePressAndHoldEnabled"] ? YES : [userDefaults boolForKey:@"ApplePressAndHoldEnabled"];

This is useful so I'd like to propose adding a toggle so when keyboard input is required I can turn it on and when it's not like when I'm just wanting more raw keyboard input, I can turn it off

Feel free to correct me, I'm not familiar with calling native code from java and I've tried to fit your calling conventions

From what I can see this would involve modifying WindowMac.java and adding a method like:

public static void setPressAndHoldEnabled(boolean enabled) {
    assert _onUIThread() : "Should be run on UI thread";
    _nSetPressAndHoldEnabled(enabled);
}

As well as modifying WindowMac.mm to add:

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowMac__1nSetPressAndHoldEnabled
  (JNIEnv *env, jclass cls, jboolean enabled) {
    jwm::kPressAndHoldEnabled = enabled;
}

Let me know if you'd prefer me to do it some other way of if you don't think this is a good way to do it =)

Otherwise happy to whip up a PR

From what I can tell I'll also need to do some work with HumbleUI to update it to get it in line with the work you've been doing to update JMW so I can use this, I don't mind putting some time in for that as well

Really want to get back into doing some gamedev on HumbleUI again, your sand example was a good reminder that there's some fun stuff that can be done here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions