We have detected that cookies are not enabled on your browser. Please enable cookies to ensure the proper experience.
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2010
    Posts
    1,491

    How to make a button Not visible?

    I got a window with 10 buttons.
    - 1 Is Not visible.
    - 9 Are Visible.

    Now when i click on any of the 9 buttons, the expected result would be:
    - The Not visible would become visible (It works perfect).
    - The 9 visible ones would become Not visible. (Not works).

    So... how can i fix that? is not making the buttons Not visible.

    Code:
                  -- Boton de Boss 3
        self.boss3Button = Turbine.UI.Lotro.Button();
        self.boss3Button:SetParent( self );
        self.boss3Button:SetPosition(235, 95);
        self.boss3Button:SetWidth( 100 );
        self.boss3Button:SetText("Boss 3");
        self.boss3Button.Click = function()
        Mypluginwindow:SetSize(500, 500);
        end
    
    function Mypluginwindow:SizeChanged(sender, args)
        Mypluginwindow.recruitButton:SetVisible( false );
        Mypluginwindow.RequerimentsButton:SetVisible( false );
        Mypluginwindow.lootButton:SetVisible( false );
        Mypluginwindow.wing1Button:SetVisible( false );
        Mypluginwindow.wing2Button:SetVisible( false );
        Mypluginwindow.wing3Button:SetVisible( false );
        Mypluginwindow.boss1Button:SetVisible( false );
        Mypluginwindow.boss2Button:SetVisible( false );
        Mypluginwindow.boss3Button:SetVisible( false );
        Mypluginwindow.volverButton:SetVisible( true );
    end
    Any help?

  2. #2
    Join Date
    Mar 2007
    Posts
    1,212
    Quote Originally Posted by Saelyth View Post
    I got a window with 10 buttons.
    - 1 Is Not visible.
    - 9 Are Visible.

    Now when i click on any of the 9 buttons, the expected result would be:
    - The Not visible would become visible (It works perfect).
    - The 9 visible ones would become Not visible. (Not works).

    So... how can i fix that? is not making the buttons Not visible.

    Code:
                  -- Boton de Boss 3
        self.boss3Button = Turbine.UI.Lotro.Button();
        self.boss3Button:SetParent( self );
        self.boss3Button:SetPosition(235, 95);
        self.boss3Button:SetWidth( 100 );
        self.boss3Button:SetText("Boss 3");
        self.boss3Button.Click = function()
        Mypluginwindow:SetSize(500, 500);
        end
    
    function Mypluginwindow:SizeChanged(sender, args)
        Mypluginwindow.recruitButton:SetVisible( false );
        Mypluginwindow.RequerimentsButton:SetVisible( false );
        Mypluginwindow.lootButton:SetVisible( false );
        Mypluginwindow.wing1Button:SetVisible( false );
        Mypluginwindow.wing2Button:SetVisible( false );
        Mypluginwindow.wing3Button:SetVisible( false );
        Mypluginwindow.boss1Button:SetVisible( false );
        Mypluginwindow.boss2Button:SetVisible( false );
        Mypluginwindow.boss3Button:SetVisible( false );
        Mypluginwindow.volverButton:SetVisible( true );
    end
    Any help?
    It appears that you are responding to the wrong event. The :SizeChanged event is fired when the size of a control changes but you indicated that you wanted the buttons to change visibility when the button is clicked, not when its window size changes. By putting the code in the SizeChanged event, ANY change to the window size will cause the nine buttons to be not visible. Additionally, the SizeChanged event will only fire if the new size is actually different from the current size, so if the window is already 500x500, :SetSize(500,500) will not fire the event again (until you set the size to something else first). I don't know how you have the other buttons such as volverButton functioning, but I suspect you were setting the size again, and that was causing the SizeChanged event to set the nine buttons not visible and the one visible.

    You should instead put all of the code that you want to execute in response to each button being clicked into that button's .Click event handler:
    Code:
                  -- Boton de Boss 3
        self.boss3Button = Turbine.UI.Lotro.Button();
        self.boss3Button:SetParent( self );
        self.boss3Button:SetPosition(235, 95);
        self.boss3Button:SetWidth( 100 );
        self.boss3Button:SetText("Boss 3");
    
        self.boss3Button.Click = function()
            self:SetSize(500, 500); -- assumes that you actually needed to change the size of the window
            self.recruitButton:SetVisible( false );
            self.RequerimentsButton:SetVisible( false );
            self.lootButton:SetVisible( false );
            self.wing1Button:SetVisible( false );
            self.wing2Button:SetVisible( false );
            self.wing3Button:SetVisible( false );
            self.boss1Button:SetVisible( false );
            self.boss2Button:SetVisible( false );
            self.boss3Button:SetVisible( false );
            self.volverButton:SetVisible( true );
         end
    
        -- you then need a separate function for the volverButton
        self.volverButton.Click = function()
            self:SetSize(500, 500); -- assuming you need to change the size in response to this button
            self.recruitButton:SetVisible( true );
            self.RequerimentsButton:SetVisible( true );
            self.lootButton:SetVisible( true );
            self.wing1Button:SetVisible( true );
            self.wing2Button:SetVisible( true );
            self.wing3Button:SetVisible( true );
            self.boss1Button:SetVisible( true );
            self.boss2Button:SetVisible( true );
            self.boss3Button:SetVisible( true );
            self.volverButton:SetVisible( false );
         end
    One point to consider is that it is usually customary to "disable" a button control (make it "greyed" out) rather than change its visibility. If you have controls that you wish to disable when a button is pressed, you can use :SetEnabled() instead of :SetVisible(). SetEnabled(false) will change Turbine.UI.Lotro.Button controls to grey background with grey text (or whatever background the current skin uses for disabled buttons) and will disable all mouse and key events for the button while preserving the layout of the interface. One of the benefits of using the Turbine.UI.Lotro.Button class versus the Turbine.UI.Button class is that it inherits all of the look and feel of the current skin.

    Also, note that I changed the control name references in the event handler from "Mypluginwindow." to "self.". There are two reasons for this, the first is that the window has been defined as a class which theoretically can have more than one instance and each instance can have child buttons so they should each refer to their own children, not the children of a specific instance. Second, I am basically lazy and don't like to type more than I have to and "self" is shorter than "Mypluginwindow" and if you ever decide to change the name of your main window or want to reuse this code in another plugin you don't have to hunt down and change all of the references (although most editors have a "replace" text feature for that).
    Last edited by Garan; Jul 19 2012 at 11:14 PM. Reason: typo

  3. #3
    Join Date
    Sep 2010
    Posts
    1,491
    Ok i used your code and it doesn't completely works as intended.

    When i first click on button 3, it changes the window and it makes the volverButton appear but it doesn't makes the other 9 dissapear.

    Now, if i click again on button 3... is when it actually makes the other 9 invisible.

    Any clue why it doesn't works in first click but it does in second click?


    By the way, the SizeChanged function was used because i need to create the Same code for the 9 Buttons, so i though it would be more efficient to just create a Function doing that same stuff and in each code just calling the function, would as well save size of the file. Not sure if that's really needed in LUA. Anyway i was just testing ways to make it work, since i wasn't able. Now your code is what i like to do, it works... but on second click Garan.

    Full code for you to test it if you want.
    Code:
                      -- Ventana principal
    function BGTier1window:Constructor()
        Turbine.UI.Lotro.Window.Constructor( self );
    
        Hellish:SetVisible( false );
    
        
    
        -- Propiedades de Ventana
        self:SetBackColor( Turbine.UI.Color() );
        self:SetSize(365, 130);
        self:SetText("Barad Guldur");
        self:SetOpacity(0.8);
        self:SetPosition( windowSettings.positionX, windowSettings.positionY );
    
                   -- Boton de Volver a BG
        self.volverButton = Turbine.UI.Lotro.Button();
        self.volverButton:SetParent( self );
        self.volverButton:SetPosition(420, 20);
        self.volverButton:SetWidth( 50 );
        self.volverButton:SetText("Back");
        self.volverButton:SetVisible( false );
        self.volverButton.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
                   -- Boton de Classes necesarias
        self.recruitButton = Turbine.UI.Lotro.Button();
        self.recruitButton:SetParent( self );
        self.recruitButton:SetPosition(35, 35);
        self.recruitButton:SetWidth( 100 );
        self.recruitButton:SetText("Recruiting");
        self.recruitButton.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
            -- Boton de requisitos
        self.RequerimentsButton = Turbine.UI.Lotro.Button();
        self.RequerimentsButton:SetParent( self );
        self.RequerimentsButton:SetPosition(135, 35);
        self.RequerimentsButton:SetWidth( 100 );
        self.RequerimentsButton:SetText("Requeriments");
        self.RequerimentsButton.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
            -- Boton de Loot que sueltan
        self.lootButton = Turbine.UI.Lotro.Button();
        self.lootButton:SetParent( self );
        self.lootButton:SetPosition(235, 35);
        self.lootButton:SetWidth( 100 );
        self.lootButton:SetText("Loot");
        self.lootButton.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
                   -- Boton de Wing 1
        self.wing1Button = Turbine.UI.Lotro.Button();
        self.wing1Button:SetParent( self );
        self.wing1Button:SetPosition(35, 65);
        self.wing1Button:SetWidth( 100 );
        self.wing1Button:SetText("Wing 1");
        self.wing1Button.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
            -- Boton de Wing 2
        self.wing2Button = Turbine.UI.Lotro.Button();
        self.wing2Button:SetParent( self );
        self.wing2Button:SetPosition(135, 65);
        self.wing2Button:SetWidth( 100 );
        self.wing2Button:SetText("Wing 2");
        self.wing2Button.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
            -- Boton de Wing 3
        self.wing3Button = Turbine.UI.Lotro.Button();
        self.wing3Button:SetParent( self );
        self.wing3Button:SetPosition(235, 65);
        self.wing3Button:SetWidth( 100 );
        self.wing3Button:SetText("Wing 3");
        self.wing3Button.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
                   -- Boton de Boss 1
        self.boss1Button = Turbine.UI.Lotro.Button();
        self.boss1Button:SetParent( self );
        self.boss1Button:SetPosition(35, 95);
        self.boss1Button:SetWidth( 100 );
        self.boss1Button:SetText("Boss 1");
        self.boss1Button.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
                          -- Boton de Boss 2
        self.boss2Button = Turbine.UI.Lotro.Button();
        self.boss2Button:SetParent( self );
        self.boss2Button:SetPosition(135, 95);
        self.boss2Button:SetWidth( 100 );
        self.boss2Button:SetText("Boss 2");
        self.boss2Button.Click = function()
        BGTier1window:SetSize(500, 500);
        end
    
                 -- Boton de Boss 3
        self.boss3Button = Turbine.UI.Lotro.Button();
        self.boss3Button:SetParent( self );
        self.boss3Button:SetPosition(235, 95);
        self.boss3Button:SetWidth( 100 );
        self.boss3Button:SetText("Boss 3");
    
        self.boss3Button.Click = function()
            self:SetSize(500, 500);
            self.recruitButton:SetVisible( false );
            self.RequerimentsButton:SetVisible( false );
            self.lootButton:SetVisible( false );
            self.wing1Button:SetVisible( false );
            self.wing2Button:SetVisible( false );
            self.wing3Button:SetVisible( false );
            self.boss1Button:SetVisible( false );
            self.boss2Button:SetVisible( false );
            self.boss3Button:SetVisible( false );
            self.volverButton:SetVisible( true );
         end
    
    -- a separate function for the volverButton
        self.volverButton.Click = function()
            self:SetSize(365, 130);
            self.recruitButton:SetVisible( true );
            self.RequerimentsButton:SetVisible( true );
            self.lootButton:SetVisible( true );
            self.wing1Button:SetVisible( true );
            self.wing2Button:SetVisible( true );
            self.wing3Button:SetVisible( true );
            self.boss1Button:SetVisible( true );
            self.boss2Button:SetVisible( true );
            self.boss3Button:SetVisible( true );
            self.volverButton:SetVisible( false );
         end
    
    
    end
    
    
                      -- Funcion al cerrar ventana principal
    function BGTier1window:Closing( args )
        Hellish:SetVisible( true );
    end
    Last edited by Saelyth; Jul 19 2012 at 04:22 PM.

  4. #4
    Join Date
    Mar 2007
    Posts
    1,212
    I'm not positive, but I suspect that you still have an event handler, probably SizeChanged, which is defined elsewhere in the plugin with the code that sets the visibility. The code you posted doesn't include the code that actually creates an instance of the BGTier1window class, so I suspect there is quite a bit of other code - I would do a search on "SetVisible(" to see if there is any other code that is handling an event and accidentally setting the visibility. The reason I suspect SizeChanged is that you are changing the size in the .Click handler, this would cause the SizeChanged event to fire the first time you click, which would override the visibility, but since the size is already changed by the first click, the second click would not fire the SizeChanged event so the conflicting event handler does not get called resulting in exactly the behaviour you are reporting. The reason I suggested to search on "SetVisible(" is that there are other event handlers that could cause the same symptoms, just not as likely. Let me know how it turns out. If you like, I can PM you an email address where you can email me the whole file and I can test it further, but I truly believe from the symptoms that you will find another event handler defined which is affecting your visibility.

    Note, you accidentally left the original definition for the boss3Button.Click handler in the code (up in the code where you define the boss3Button) with just the size change but that is not causing your problem as that definition gets overwritten by the one that also has the visibility setting statements.

    Also, from the code snippet that you posted, it looks as though you are planning on creating a new instance of the window each time you display it (you hide what appears to be the parent window, "Hellish", in the constructor of the class). You should know that "closing" a window does not destroy it, you would have to remove all references to the window in order to actually remove it. Closing it just makes it not visible. Instead of hiding the parent window in this window's constructor, you should hide the parent window in whatever code displays this child window and you should only create one instance of this child window (hiding and displaying as needed). For instance, if you have your parent window "Hellish" and it has a button to display this child, I will call it "BGButton" and if you call this child window BGWindow then the code would be something like:
    Code:
    -- in the "Hellish" constructor
        self.BGButton.Click=function()
            self:SetVisible(false) -- hides the "Hellish" window
            if BGWindow==nil then
                BGWindow=BGTier1window (); -- creates the child if it wasn't previously created
            end
            BGWindow:SetVisible(true); -- displays the child
        end
    then you can use the Closing event handler of the child to redisplay the parent window as you have already implemented it and you will have one instance of the child that displays as needed and the parent window will get hidden and displayed appropriately.
    Last edited by Garan; Jul 19 2012 at 09:33 PM. Reason: clarification

  5. #5
    Join Date
    Sep 2010
    Posts
    1,491
    I think i'm gonna post here the files because i honestly think i did a really big fail programming this.

    Explaining how it works a bit:
    - When you load the plugin, it first load a Loader NotVisible window called "Cargador"
    - Then, Cargador instantly loads the Hellish window.
    - The hellish window is what i call my "main" menu window. From it you can access to all the options of the plugin.
    - BG1 is one of the sections of Hellish, so when i click on the BG button the Hellish windows dissapears because i would be in a different section, and since i don't know how to create "Tabs" i'm trying this weird stuff.
    - To end with, inside the BG section i got to make 9 sections, so i though i could use the "Hide" all the controls of all sections (yes, they would be all them loaded on same place as Not Visible.) (Labels, buttons, images...) and each time someone click on 1 Section, the plugin would only make visible the controls regarding to that section. That way the trick would fake 9 different sections making some controls visibles or not visible in the same window.
    - When you close the BG window it makes hellish visible again.

    https://rapidshare.com/files/2202058...ythPlugins.rar

    I'm gonna be trying to find what happens but i don't have so much hope.
    Last edited by Saelyth; Jul 20 2012 at 02:54 AM.

  6. #6
    Join Date
    Mar 2007
    Posts
    1,212
    Quote Originally Posted by Saelyth View Post
    I think i'm gonna post here the files because i honestly think i did a really big fail programming this.

    Explaining how it works a bit:
    - When you load the plugin, it first load a Loader NotVisible window called "Cargador"
    - Then, Cargador instantly loads the Hellish window.
    - The hellish window is what i call my "main" menu window. From it you can access to all the options of the plugin.
    - BG1 is one of the sections of Hellish, so when i click on the BG button the Hellish windows dissapears because i would be in a different section, and since i don't know how to create "Tabs" i'm trying this weird stuff.
    - To end with, inside the BG section i got to make 9 sections, so i though i could use the "Hide" all the controls of all sections (yes, they would be all them loaded on same place as Not Visible.) (Labels, buttons, images...) and each time someone click on 1 Section, the plugin would only make visible the controls regarding to that section. That way the trick would fake 9 different sections making some controls visibles or not visible in the same window.
    - When you close the BG window it makes hellish visible again.

    https://rapidshare.com/files/2202058...ythPlugins.rar

    I'm gonna be trying to find what happens but i don't have so much hope.
    The overall design sounds just fine (I'm not sure you need Cargador to load Hellish, but that's just a difference in design philosophy, not really right or wrong). As to creating Tabs in Lua, the system does not actually have a Tab control so we have to simulate it in a way which is very close to exactly what you are doing. We use a series of buttons to control which tab is displayed, highlighting whichever button is tied to the current tab and a series of container controls that are all overlaid and only the "current" one is set to visible. When you add a border to the container which blends with the "current" button you can create a fairly good tab control.

    I will take a look at the files you posted later today. I suspect you are in better shape than you think.

    EDIT:
    OK. I've had a chance to look at the files and the problem is not quite what I thought it was. The buttons on the window where you are clicking ARE being set to not visible. The problem is that you have created TWO of the child windows and the one underneath is showing through the one on top so the bottom window's buttons are still visible. The problem occurs in your HellishWindow.lua file. The button Click handler for apartnotasButton is
    Code:
    self.apartnotasButton.Click = function()
        BGTier1window:Constructor();
        BGTier1window():SetVisible( true );
    end
    There are a couple problems. The line "BGTier1window:Constructor ()" is calling the constructor for a BGTier1window class object. This is not the correct way to display an instance of a window. You should be creating a single instance by calling "BGTier1window()" not "BGTier1window:Constructor ()" and second you should be assigning that instance to a variable so that you can reuse it. The cause of the duplicate window though is the second line, BGTier1window():SetVisible ( true ). This line creates a second instance of the BGTier1window class and then calls the second instance's SetVisible method. This Click handler should instead look like:
    Code:
    self.apartnotasButton.Click=function()
        if bgtier1window==nil then
            bgtier1window=BGTier1window() -- creates a single instance of the class. note, putting the parentheses after the class name creates and instance of the class and calls the constructor of the class for that instance
        end
        self:SetVisible(false) -- hides the HellishWindow
        bgtier1window:SetVisible(true) -- displays the instance of the BGTier1window. note there are no parentheses after the instance name since we don't want to call it's constructor again.
    end
    You also have a small problem in the BGTier1window.lua file. You added 3 "durchest" controls and set their visibility=true in the boss3Button.Click handler but forgot to add lines to make them not visible in the volverButton.Click handler. Once you change the HellishWindow button handlers to the format above and add the code to the volverButton handler to make the durchest text not visible, the plugin works as you intended.

    I don't want to overly influence your design as that could stifle your creative process, but I would suggest modifying the design to use a single, reusable, display window and just change the contents of the display window in the HellishWindow Click handlers, separating the data being displayed from the control performing the display. You can create an array of values for the display window buttons so that the child window only shows the correct number of buttons and they call the correct functions when clicked. Then you can create a table of text values to be displayed as each button is clicked. This may sound complicated at first, but it is actually quite easy and can be very easily extended by simply adding more data without the need for extra controls for each display. Basically, I would create a single new class that would replace the BGTier1window, DraigochTier2window, etc. The dislay window would then have it's contents changed based on which button is clicked in the HellishWindow. Send me a PM if you would like a more detailed description.
    Last edited by Garan; Jul 20 2012 at 11:57 AM.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

This form's session has expired. You need to reload the page.

Reload