Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 10 handleInputModeList issue #107

Open
pirrate opened this issue Sep 25, 2016 · 10 comments
Open

iOS 10 handleInputModeList issue #107

pirrate opened this issue Sep 25, 2016 · 10 comments

Comments

@pirrate
Copy link

pirrate commented Sep 25, 2016

I am trying to implement handleInputModeList that was added in iOS10. This is my code

  case Key.KeyType.keyboardChange:
   if #available(iOSApplicationExtension 10.0, *) {
     keyView.addTarget(self, action: #selector(self.handleInputModeList(from:with:)), for:UIControlEvents.allTouchEvents)
     } else {
     keyView.addTarget(self, action: #selector(KeyboardViewController.advanceTapped(_:)), for: .touchUpInside)
 }

But it doesnt work. I tried to create new button and add same target there and it worked normally. But it doesnt work with keyViews. Any idea?

@pirrate
Copy link
Author

pirrate commented Sep 26, 2016

@archagon @AaronFW any idea how to handle it?

@AaronFW
Copy link

AaronFW commented Sep 27, 2016

I haven't had much chance to try using it.

@AaronFW
Copy link

AaronFW commented Sep 27, 2016

Well, I think it is because handleInputModeList(from:with) is a method of UIInputViewController but keyView is KeyboardKey Class and KeyboardKey Class is UIControl (which inherits from UIView).

Or in other words, they are different branches of UIKit, but they don't inherit the same functions.
UIKit > UIInputViewController
UIKit > UIControl

Typically when handleInputModeList is used, it is used directly in the UIInputControlView class declaration. For example, one project I looked at had
self.nextKeyboardButton.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
In which "self" was the class KeyboardControllerView: UIInputControllerView

Though, since I am a novice at programming, the problem could be something else. :P

@pirrate
Copy link
Author

pirrate commented Sep 29, 2016

@AaronFW I think the main reason is because @archagon rewriting events on forwardingview and handleInputModeList(from:with:) is something that it doesnt understand. Normally if i add extra UIButton to forwardingview and add same target it works without any problem. Now i dont know how to figure it out with this architecture.

@mromanuk
Copy link

mromanuk commented Jan 5, 2018

@pirrate you are right, I needed to change the way ForwardingView and KeyboardKey track touch.

That allow me to do this in keyboardViewController.setupKeys():

keyView.addTarget(self, action: #selector(handleInputModeList(from:with:)), for: .allTouchEvents)
keyView.originalViewTouch = true

the originalViewTouch is a flag to use the native UIControl tracking capability instead of the Archagon keyboard tracking in ForwardingView.hitTest

@ifanchu
Copy link

ifanchu commented Jan 20, 2018

@mromanuk do you mind shedding some light on how to implement this? Some code snippets maybe? Appreciated.

@ifanchu
Copy link

ifanchu commented Jan 21, 2018

I think I figure it out, thanks for the tip @mromanuk

@vishal07malvi
Copy link

vishal07malvi commented Aug 4, 2018

@ifanchu @mromanuk @archagon @AaronFW could you please let me know this issue is fixed or not? because I also having issue with
keyView.addTarget(self, action: #selector(self.handleInputModeList(from:with:)), for:UIControlEvents.allTouchEvents)
handleInputModeList, Could you please let me know what should I do with this?

@kamalupasena
Copy link

@ifanchu Can you share a code sample ?

@aalenliang
Copy link

Here is my full solution to this issue, don't know if it's the best approach. thanks for @mromanuk sharing the tips.

in KeyboardKey.swift, add originalViewTouch property:

var originalViewTouch = false

in KeyboardViewController.swift, setupKeys function:

case Key.KeyType.keyboardChange:
    keyView.addTarget(self,
                      action: #selector(handleInputModeList(from:with:)),
                      for: .allTouchEvents)
    keyView.originalViewTouch = true

and delete advanceTapped method.

in ForwardingView.swift, hitTest function:
replace

else {
    return (self.bounds.contains(point) ? self : nil)
}

with

if !self.bounds.contains(point) {
    return nil
}
if let view = self.findNearestView(point),
    let keyView = view as? KeyboardKey,
    keyView.originalViewTouch {
    return keyView
}
return self

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants