1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default Tip: when changing a component to floating, be sure to hide it first

    Tip: when changing a component to floating, be sure to hide it first


    Just throwing this out there in case anyone else finds it helpful. I was fighting for a while trying to figure out why my code to set a non-floating panel to a floating one caused it to be weirdly offset. This might even ought to be classified as a bug. Anyway, before you remove it from the parent, you need make sure you hide it. Example:

    Code:
    <html>
      <head>
        <title>test</title>
        <link rel="stylesheet" href="sencha/resources/css/sencha-touch-debug.css" type="text/css">
        <script type="text/javascript" src="sencha/sencha-touch-debug.js"></script>  
    
        <script type="text/javascript">
          
    Ext.setup({
      onReady: function() {
        float = new Ext.Panel({
          style:'background-color: #C0C0FF',
          html:'float'
        });
    
        mainPanel = new Ext.Panel({
          layout:'fit',
          fullscreen:true,
          items:[float],
          dockedItems:{xtype:'toolbar', dock:'bottom', items:[
            {xtype:'button', text:'float', handler:function() { makefloat(float) } }
          ]}
        });
        
        function makefloat(cmp) {
          cmp.hide();  // comment this out and it screws up
          mainPanel.remove(cmp, false);
          cmp.setPosition(10, 10);
          cmp.setFloating(true);
          cmp.hideOnMaskTap = false;
          cmp.show();
          cmp.setHeight(100);
          cmp.setWidth(100);      
        }
      }
    });
    
        </script>
      </head>
    
      <body></body>
    </html>
    If you don't do it that way (and to some degree, in that order), it doesn't work right.

    Of course, maybe there's some obscure method I should be using instead and I'm just doing it all wrong anyway.

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Posts
    7
    Vote Rating
    0
    Gary Pickrell is on a distinguished road

      0  

    Default


    Thank you for posting this. I've been struggling to get floating to work. Your example is the first case I've seen where it does. Now I'm running amuck with floats =)

Similar Threads

  1. using floating - my component just vanishes, even with absolute pos.
    By DaveC426913 in forum Sencha Touch 1.x: Discussion
    Replies: 6
    Last Post: 26 Nov 2010, 7:39 AM
  2. Replies: 1
    Last Post: 21 Oct 2010, 3:47 PM
  3. Main panel tool tip is overlapping with the component tool tip.
    By bharathslip9 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 18 Sep 2010, 9:23 AM
  4. changing the focus of the Component
    By josephraja1982 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 19 Nov 2007, 11:00 PM
  5. [2.0b1] Floating Panel Hide / Show Bug
    By martyn in forum Ext 2.x: Bugs
    Replies: 4
    Last Post: 8 Nov 2007, 2:06 AM

Thread Participants: 1