tasty-imitation-keyboard icon indicating copy to clipboard operation
tasty-imitation-keyboard copied to clipboard

Long press keys

Open bbqsrc opened this issue 10 years ago • 26 comments

I know you've said you'll tackle this later, but I thought I'd open this for consideration.

We just discussed in another bug the requirement for a banner due to the view not being able to have popups extend outside which is unfortunate.

If the popups are on the left and right, that'd have implications for the long press implementation.

Is it possible to resize the view on the fly?

bbqsrc avatar Oct 08 '14 13:10 bbqsrc

Unfortunately, Apple's way of resizing the keyboard view is a bit hacky, so even though you can resize it on the fly, it might be too slow for practical purposes. I'll look into it, though. I assume you're thinking of having the banner section appear only when pressing the top row keys?

archagon avatar Oct 08 '14 13:10 archagon

Yeah, if it were possible. At least the banner area can be useful, for dictionary support, etc.

bbqsrc avatar Oct 08 '14 13:10 bbqsrc

Preliminary experiments have shown that it might be possible to do, but it's not straightforward. I'll consider working on this feature later; right now, more important stuff to do.

archagon avatar Oct 08 '14 18:10 archagon

I understand your not wishing to tackle creating extended popups right now! However, being able to detect a long press on a key would be very useful for extendability--caps lock and so on. Just getting a keyLongPressed callback, for instance, would at least let others be able to create their own UI.

alariccole avatar Oct 29 '14 17:10 alariccole

+1

bhagyas avatar Nov 09 '14 18:11 bhagyas

+1

sparhawk85 avatar Nov 12 '14 21:11 sparhawk85

A lot of +1's here :) I could probably do a pull request if it's easier for you, but I think it'd be a simple addition to just set a timer and flag on touchesBegan, ensure the movement doesn't go out of a predefined bounds on touchesMoved, and fire a keyLongPressed method. Might be able to make this work with a longpressgesture too, not sure which is easier to implement. (Bought your app by the way. Anyone else using this framework should at least do that as well!)

alariccole avatar Nov 12 '14 21:11 alariccole

Hey, thanks! Aside from the special character popups, what is a long press used for? I could add a long press recognizer, but if people want to implement their own special character pickers, they'd need to do a lot more work involving special casing the forwarding view to pass on touches to the picker once it's open, as well as dealing with the crazy bezier curve stuff in KeyboardKey. So I don't know if it would really be all that useful.

archagon avatar Nov 12 '14 22:11 archagon

Yeah, that's probably true. Didn't consider the complications in forwarding touches. I may be biased here in its utility.

alariccole avatar Nov 12 '14 22:11 alariccole

Would still be useful for special keys like Caps, that could use a long press to toggle a setting, or to detect keys that could repeat. For instance, you have a custom timer for backspace, but this could be extended easily to any key that opts in to a long press, and devs could choose to repeat or perform another action.

alariccole avatar Nov 12 '14 22:11 alariccole

Yes it will be really challenging to deal with brazier curve stuff and so on. but still will be useful if you implement long press so we can open our custom popup view event it will not be similar to iPhones default at the beginning.

pirrate avatar Nov 18 '14 19:11 pirrate

i am playing around trying to add longpress at setupKeys() but it does not fire an action. Does it somehow disable all gestures somewhere?

                    let lp = UILongPressGestureRecognizer(target: self, action: "keyLongPress:")
                    lp.minimumPressDuration = 1.2
                    lp.numberOfTapsRequired = 1
                    keyView.addGestureRecognizer(lp)

so here func KeyLongPress never being called.

pirrate avatar Nov 20 '14 19:11 pirrate

Are you adding the gesture recognizer to each key? It's not going to work because everything goes through the forwarding view right now. The keys don't actually receive any touches.

archagon avatar Nov 20 '14 20:11 archagon

Actually the point is to add for individual key but just for testing i put code to if key.hasOutput { part. Anyway if it does not receive any touches then it wont work even for individual key. What you suggest todo? Now i am trying to figure it out the same way you do for backspace button.

pirrate avatar Nov 20 '14 21:11 pirrate

huh did it with timers. works fine :)

pirrate avatar Nov 20 '14 21:11 pirrate

Yeah, that should work. You could also try adding the gesture recognizer to the forwarding view and checking if your touch is inside a key's bounds, but that is a more gnarly approach. (Though perhaps ultimately the more elegant one...)

archagon avatar Nov 20 '14 21:11 archagon

What is the exact reason of using forwarding view? don`t you think it is decreasing the performance?

pirrate avatar Nov 20 '14 21:11 pirrate

If I don't use a forwarding view, it's impossible to slide your finger from one button to another. TouchDragEnter doesn't fire unless the touch starts in that control to begin with.

archagon avatar Nov 20 '14 21:11 archagon

Oh, so you are thinking about future, to make "type by sliding" functionality :+1: :))

pirrate avatar Nov 20 '14 21:11 pirrate

No, I mean on the keyboard, when you hold down a key and then slide your finger over to another key, the popup for the first key closes and the popup for the second key opens up. You couldn't do that without a forwarding view, i don't think.

archagon avatar Nov 20 '14 21:11 archagon

I understood you man :) Just wanted to kindly egg you on to start thinking about slide typing :))

pirrate avatar Nov 20 '14 21:11 pirrate

@pirrate did you actually implement a long-press solution? Would you share it?

SchSimon avatar Jan 04 '15 01:01 SchSimon

Hi @SchSimon , i am using the same technique that @bbqsrc did. Check out his fork https://github.com/bbqsrc/tasty-imitation-keyboard/blob/master/Keyboard/KeyboardViewController.swift

pirrate avatar Jan 04 '15 08:01 pirrate

Refers to this link, I have make changes in this keyboard. It may help you https://github.com/AmitBhavsarIphone/Custom-keyboard It contains, Different keyboard type changes, Long popup with different alphabet options, Suggestion bar with text in it. Constraint changes for different keyboard type.

amit-bhavsar avatar May 19 '15 10:05 amit-bhavsar

@AmitBhavsarIphone thanks for sharing. Does the host app showcase these new additions? Sounds very useful.

alariccole avatar May 19 '15 17:05 alariccole

Hi @alariccole It showcase new additions, Looking forward to make

  • Suggestions, prediction and autocorrection using N-gram and other algorithms and fastest fetching method from dictionary database.

amit-bhavsar avatar May 20 '15 05:05 amit-bhavsar