Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28404] iOS: tabGroup.setActiveTab() and text.setSelection() shows an error

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2021-04-05T14:51:22.000+0000
Affected Version/sRelease 10.1.0, Release 10.0.0
Fix Version/sRelease 10.0.0
ComponentsiOS
Labelsn/a
ReporterSamir Mohammed
AssigneeVijay Singh
Created2021-03-24T14:33:50.000+0000
Updated2021-04-12T22:15:20.000+0000

Description

When running the code below the following error is shown, the docs state that setActiveTab() should also work on iOS and not just on Android. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TabGroup-method-setActiveTab https://github.com/appcelerator/titanium_mobile/blob/f6408505023dd85a4b13857130e0ef31289cc870/apidoc/Titanium/UI/TabGroup.yml#L271-L276 *Error:*
[ERROR]  file:///app.js:26
[ERROR]  (null)
[ERROR]   ^
[ERROR]  TypeError: tabGroup.setActiveTab is not a function. (In 'tabGroup.setActiveTab(1)', 'tabGroup.setActiveTab' is undefined)
[ERROR]   at Object.<anonymous> (file:///app.js:26:24)
[ERROR]  
[ERROR]   Foundation 0x00007fff2084c37a _NSDescriptionWithLocaleFunc + 82
[ERROR]   CoreFoundation 0x00007fff203bae0d __CFStringAppendFormatCore + 12102
[ERROR]   CoreFoundation 0x00007fff203bc8a1 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 145
[ERROR]   CoreFoundation 0x00007fff203bc80a _CFStringCreateWithFormatAndArgumentsAux2 + 20
[ERROR]   TitaniumKit 0x0000000100608f4a TiLogMessage + 175
[ERROR]   TitaniumKit 0x0000000100645f08 -[TiExceptionHandler reportScriptError:] + 74
[ERROR]   TitaniumKit 0x0000000100632dae TiBindingEventProcess + 731
[ERROR]   TitaniumKit 0x000000010065427b -[KrollContext invoke:] + 109
[ERROR]   TitaniumKit 0x00000001006542ee -[KrollContext enqueue:] + 93
[ERROR]   TitaniumKit 0x000000010065b6d0 TiBindingRunLoopEnqueue + 77
[ERROR]   TitaniumKit 0x0000000100632e35 TiBindingEventProcess + 866
[ERROR]   TitaniumKit 0x000000010065427b -[KrollContext invoke:] + 109
[ERROR]   TitaniumKit 0x00000001006542ee -[KrollContext enqueue:] + 93
[ERROR]   TitaniumKit 0x000000010065b6d0 TiBindingRunLoopEnqueue + 77
[ERROR]   TitaniumKit 0x0000000100659dd5 -[TiProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 187
[ERROR]   TitaniumKit 0x000000010063ab5f -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 224
[ERROR]   TitaniumKit 0x0000000100659bcb -[TiProxy fireEvent:withObject:propagate:] + 76
[ERROR]   TitaniumKit 0x000000010062bcb3 -[TiUIView touchesEnded:withEvent:] + 110
*Test Case:*
var win1 = Ti.UI.createWindow({
 backgroundColor: 'blue',
 title: 'Blue'
});
win1.add(Ti.UI.createLabel({text: 'I am a blue window.'}));

var win2 = Ti.UI.createWindow({
 backgroundColor: 'red',
 title: 'Red'
});
win2.add(Ti.UI.createLabel({text: 'I am a red window.'}));

var tab1 = Ti.UI.createTab({
 window: win1,
 title: 'Blue'
}),
tab2 = Ti.UI.createTab({
 window: win2,
 title: 'Red'
}),
tabGroup = Ti.UI.createTabGroup({
 tabs: [tab1, tab2]
});

win1.addEventListener('click', () => {
 tabGroup.setActiveTab(1);
})
tabGroup.open();
*text.setSelection()* *code*
var text = Ti.UI.createTextField({top: 100, value: "This is Sparta."});
//var text = Ti.UI.createTextArea({top: 100, value: "This is Sparta."});

 

var win = Ti.UI.createWindow({backgroundColor: "#fff"});
var button = Ti.UI.createButton({bottom: 50, title: "text selection"});
button.addEventListener('click', function(e) {
    text.setSelection(0, 4);
});

 

win.add(text);
win.add(button);
win.open();
*Error*
[ERROR]  file:///app.js:8
[ERROR]  (null)
[ERROR]   ^
[ERROR]  TypeError: text.setSelection is not a function. (In 'text.setSelection(0, 4)', 'text.setSelection' is undefined)
[ERROR]   at Object.<anonymous> (file:///app.js:8:20)
[ERROR]  
[ERROR]   Foundation 0x00007fff2084c37a _NSDescriptionWithLocaleFunc + 82
[ERROR]   CoreFoundation 0x00007fff203bae0d __CFStringAppendFormatCore + 12102
[ERROR]   CoreFoundation 0x00007fff203bc8a1 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 145
[ERROR]   CoreFoundation 0x00007fff203bc80a _CFStringCreateWithFormatAndArgumentsAux2 + 20
[ERROR]   TitaniumKit 0x0000000107a00f3d TiLogMessage + 175
[ERROR]   TitaniumKit 0x0000000107a3def8 -[TiExceptionHandler reportScriptError:] + 74
[ERROR]   TitaniumKit 0x0000000107a2ad9e TiBindingEventProcess + 731
[ERROR]   TitaniumKit 0x0000000107a4c26b -[KrollContext invoke:] + 109
[ERROR]   TitaniumKit 0x0000000107a4c2de -[KrollContext enqueue:] + 93
[ERROR]   TitaniumKit 0x0000000107a536c0 TiBindingRunLoopEnqueue + 77
[ERROR]   TitaniumKit 0x0000000107a51dc5 -[TiProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 187
[ERROR]   TitaniumKit 0x0000000107a32b4f -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 224
[ERROR]   aneww 0x000000010758ff30 -[TiUIButtonProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 272
[ERROR]   TitaniumKit 0x0000000107a51ad9 -[TiProxy fireEvent:withObject:] + 72
[ERROR]   aneww 0x0000000107592ade -[TiUIButton controlAction:forEvent:] + 686
[ERROR]   UIKitCore 0x00007fff2469d19e -[UIApplication sendAction:to:from:forEvent:] + 83
[ERROR]   UIKitCore 0x00007fff23fc6684 -[UIControl sendAction:to:forEvent:] + 223
[ERROR]   UIKitCore 0x00007fff23fc69a7 -[UIControl _sendActionsForEvents:withEvent:] + 332

Comments

  1. Vijay Singh 2021-03-24

    PR - https://github.com/appcelerator/titanium_mobile/pull/12654 Note - 1. setSelection (textfield)- Fixed in code as this is issue
       //var text = Ti.UI.createTextField({top: 100, value: "This is Sparta."});
       var text = Ti.UI.createTextArea({top: 100, value: "This is Sparta."});
       
       var win = Ti.UI.createWindow({backgroundColor: "#fff"});
       var button = Ti.UI.createButton({bottom: 50, title: "text selection"});
       button.addEventListener('click', function(e) {
           text.setSelection(0, 4);
          setTimeout(function(e) {
           Ti.API.info(text.selection.length);
           Ti.API.info(text.selection.location);	
       }, 1000);
       });
       
       win.add(text);
       win.add(button);
       win.open();
       
    2. setTabSelection (tabgroup) - This is property. So updated doc and it should be used as tabGroup.tabSelection
       var win1 = Ti.UI.createWindow({
        backgroundColor: 'blue',
        title: 'Blue'
       });
       win1.add(Ti.UI.createLabel({text: 'I am a blue window.'}));
       
       var win2 = Ti.UI.createWindow({
        backgroundColor: 'red',
        title: 'Red'
       });
       win2.add(Ti.UI.createLabel({text: 'I am a red window.'}));
       
       var tab1 = Ti.UI.createTab({
        window: win1,
        title: 'Blue'
       }),
       tab2 = Ti.UI.createTab({
        window: win2,
        title: 'Red'
       }),
       tabGroup = Ti.UI.createTabGroup({
        tabs: [tab1, tab2]
       });
       
       win1.addEventListener('click', () => {
        tabGroup.activeTab = 1;
       })
       tabGroup.open();
       
  2. Christopher Williams 2021-03-26

    merged to master, backport PR merged on 10_0_X https://github.com/appcelerator/titanium_mobile/pull/12666
  3. Joshua Quick 2021-03-26

    Below PR addresses the Android side of this ticket... PR (master): https://github.com/appcelerator/titanium_mobile/pull/12661
  4. Christopher Williams 2021-04-05

    merged android PR https://github.com/appcelerator/titanium_mobile/pull/12661 to master, backport to 10_0_X done via manual cherry-pick and conflict resolution.
  5. Michael Gangolf 2021-04-12

    Something broke for me in Android 10.1.0 master and the example from https://github.com/appcelerator/titanium_mobile/pull/12693 is not working for me either {noformat} [ERROR] TabGroupProxy: (main) [72,72] Invalid tab index. [ERROR] TabGroupProxy: (main) [18,278] Cannot activate tab not in this group. {noformat} and the tabs are empty. In my app where I assign icons in my controller:
       $.tab1.icon=Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"icon_list.png").read()
       
    I'll end up with: {noformat} [ERROR] TiExceptionHandler: $.tab1.icon=Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,"icon_list.png").read(), [ERROR] TiExceptionHandler: ^ [ERROR] TiExceptionHandler: Error: Windows are created during open {noformat} If I go back to https://github.com/appcelerator/titanium_mobile/tree/e128bd9f0017cb90ba13729b7d6ee7f25f7af786 it works fine again
  6. Joshua Quick 2021-04-12

    [~michael], I'm able to reproduce the crash. I've written up a separate ticket here: [TIMOB-28418] Thanks for brining this up.

JSON Source