pec1985 / TiSMSView

Expandable Text Area Module - iOS - Titanium
Other
60 stars 18 forks source link

textArea focus on load #16

Closed sindresorhus closed 13 years ago

sindresorhus commented 13 years ago

Is there a way to get the textArea to be focused when the app opens?

I've tried adding textArea.focus(); to the example app, but it just crashes:

2011-09-17 02:36:59.636 Nynorsk2[85673:18a07] bool _WebTryThreadLock(bool), 0x6b22c60: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

It works if I focus the textArea in the window focus event:

win.addEventListener('focus', function() {
    textArea.focus();
});

But then it only focuses after the app has loaded, so it's a noticeable keyboard slideup animation. Activating .focus() on the built-in textArea works without having to have it in the window focus event.

Can you try to fix this?

pec1985 commented 13 years ago

Fixed the crash in this commit: 3a6a1ce19b8fa1525f5585dbf64d422f6edc7e66 but now the textfield disappears (at least there is not more crash)

Not sure if this is actually possible, for the other Ti textfields, you need to call the blur after the window has opened. I will research and see if it can be done.

sindresorhus commented 13 years ago

I tried the latest commit 78eb297f0181c4f212d788e2f70b40657e8c8cdb and the textArea.focus() works outside the window focus event, as long as it's below the code that adds the textArea to the window, logical enough. But the keyboard still slides up after the window has loaded. Seems like this is how it's intended to work. Maybe you could add a property to the .createSMSView() called focusedOnLoad: true or something like that, that makes the textArea already focused when the window opens?

pec1985 commented 13 years ago

Will not fix at the moment.I don't think it's possible to show the keyboard without animation. I will research.

pec1985 commented 13 years ago

Not doable, confirmed with Titanium iOS engineer and Apple's documentation.

Closing