Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Window within view is not clickable

In my app I'm trying to create a window that contains some controls including a view. Within that view I want to have a window containing other controls. The problem is, none of the controls in the window inside the view are functionable. I've tried changing the touchEnabled property of the view between true and false, and neither seems to help.

Here's an stripped-down example of the code that shows the problem I'm encountering:


var win1 = Titanium.UI.createWindow({
    backgroundColor: "#c60" // Orange

var view1 = Titanium.UI.createView({
    top: 0, left: 0, height: 300, width: 300,
    touchEnabled: false

var win2 = Titanium.UI.createWindow({
    backgroundColor: "#c09" // Fuschia
win2.addEventListener("open", function(e) {
    Titanium.API.info("Window 2 opened");

var btn1 = Titanium.UI.createButton({
    top: 5, left: 5, height: 60, width: 250,
    title: "Test Button"
btn1.addEventListener("click", function(e) {
    alert("You clicked me!");



A couple things are happening. First of all, the win2 window automatically opens when added to the view even though the .open() method was never called. And secondly, the button inside win2 is not clickable at all.

Like I said, I've tried it with the touchEnabled property toggled either way and it has no effect. Any ideas?

— asked November 13th 2010 by Levi Wiederstein
  • iphone
  • touchenabled
  • view
  • window
  • you mention two problems here… touch not working and window opening? which one works when toggling and which doesnt

    — commented November 13th 2010 by Aaron Saunders
  • both issues are the same whether touchEnabled is true or false.

    — commented November 14th 2010 by Levi Wiederstein

2 Answers

  • Accepted Answer

    Hi Levi,

    Firstly, I'd like to tell you that it's a rare event to find someone who actually recognises a term like "stripped-down example", let alone one whose code is complete enough to demonstrate the issue without any hacking and emulator restarts. Even though I was ready to close down for the night, I was so surprised, that I started everything up again! :)

    And now I have just noticed that you have even tagged it correctly with your target platform! I want to vote your post 1000 times so that everyone sees the fine example that it sets! ;)

    I can see that you have the right idea with your code, but the problem is that you cannot add a window to a view. Conversely, you can add a view to a window. I could immediately see a description of the problem when I ran your code because I was running android's adb -e logcat to see logging messages, which showed:

    java.lang.IllegalStateException: call to getView on a Window

    Obviously that's not an option for you when working with the apple's sdk, but you could use the
    TiDev Run Emulator screen and set the filter at the bottom to "Trace".

    So, replace the last 4 lines of your code with the following and it will work.


    However, I am mindful that this won't give you your original intended result. Would you have a look at it again, with the information about adding views in mind, and if you need further help, let me know what you are aiming for and I will help you through it.

    Good luck, and enjoy it!

    — answered November 16th 2010 by Paul Dowsett
    1 Comment
    • Thanks for that note of debugging. I wasn't aware that Titanium didn't allow for windows to be added to views. The main reasoning I wanted to do it in the first place was so I could separate my code out (using the url property of the window object, since views don't allow for urls).

      I've seen learned however that there's a bunch of problems with using the url property on a window (such as not being able to animate the window upon opening). So I've had to rewrite my code considerably anyways.

      Thanks for the answer though. Much appreciated.

      — commented November 16th 2010 by Levi Wiederstein
  • I just had a similar trouble, so I'd like to to add that adding a window to a window will lead to the same exception :

    java.lang.IllegalStateException: call to getView on a Window

    So you have to remind that you can nest views but not windows.

    — answered July 26th 2011 by Eric Plaquevent
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.