fn select_by_index_internal(&mut self, ctx: &mut Context, mut index: usize) {
        //No tabs could be selected if there are no one, so return immediately
        if self.tabs.is_empty() {
            return;
        }

        //If the passed index is greater than tab count, select the last one
        if index >= self.tabs.len() && index != 0 {
            index = self.tabs.len() - 1;
        }

        if self.selected != index {
            let current_tab = self.tabs[self.selected];
            let new_tab = self.tabs[index];

            //Toggle current button, the new button is toggled by user click
            ctx.get_widget(current_tab.0).set("selected", false);
            toggle_flag("selected", &mut ctx.get_widget(current_tab.0));
            ctx.get_widget(current_tab.0).update(true);

            //Hide current body
            ctx.get_widget(current_tab.1)
                .set("visibility", Visibility::Collapsed);

            ctx.get_widget(new_tab.0).set("selected", true);
            toggle_flag("selected", &mut ctx.get_widget(new_tab.0));
            ctx.get_widget(new_tab.0).update(false);

            //Show new body
            ctx.get_widget(new_tab.1)
                .set("visibility", Visibility::Visible);

            self.selected = index;
        }
    }
/**
    Change the selected tab by index. Unlike the public "select_by_index", this happen immediately.
    */
Change the selected tab by index. Unlike the public "select_by_index", this happen immediately.
Change the selected tab by index . Unlike the public " select_by_index " this happen immediately .
fn select_by_index_internal(&mut self, ctx: &mut Context, mut index: usize) {
        //No tabs could be selected if there are no one, so return immediately
        if self.tabs.is_empty() {
            return;
        }
        //If the passed index is greater than tab count, select the last one
        if index >= self.tabs.len() && index != 0 {
            index = self.tabs.len() - 1;
        }
        if self.selected != index {
            let current_tab = self.tabs[self.selected];
            let new_tab = self.tabs[index];
            //Toggle current button, the new button is toggled by user click
            ctx.get_widget(current_tab.0).set("selected", false);
            toggle_flag("selected", &mut ctx.get_widget(current_tab.0));
            ctx.get_widget(current_tab.0).update(true);
            //Hide current body
            ctx.get_widget(current_tab.1)
                .set("visibility", Visibility::Collapsed);
            ctx.get_widget(new_tab.0).set("selected", true);
            toggle_flag("selected", &mut ctx.get_widget(new_tab.0));
            ctx.get_widget(new_tab.0).update(false);
            //Show new body
            ctx.get_widget(new_tab.1)
                .set("visibility", Visibility::Visible);
            self.selected = index;
        }
    }
fn select_by_index_internal ( & mut self , ctx : & mut Context , mut index : usize ) { //No tabs could be selected if there are no one, so return immediately if self . tabs . is_empty ( ) { return ; } //If the passed index is greater than tab count, select the last one if index >= self . tabs . len ( ) && index != 0 { index = self . tabs . len ( ) - 1 ; } if self . selected != index { let current_tab = self . tabs [ self . selected ] ; let new_tab = self . tabs [ index ] ; //Toggle current button, the new button is toggled by user click ctx . get_widget ( current_tab . 0 ) . set ( " " , false ) ; toggle_flag ( " " , & mut ctx . get_widget ( current_tab . 0 ) ) ; ctx . get_widget ( current_tab . 0 ) . update ( true ) ; //Hide current body ctx . get_widget ( current_tab . 1 ) . set ( " " , Visibility :: Collapsed ) ; ctx . get_widget ( new_tab . 0 ) . set ( " " , true ) ; toggle_flag ( " " , & mut ctx . get_widget ( new_tab . 0 ) ) ; ctx . get_widget ( new_tab . 0 ) . update ( false ) ; //Show new body ctx . get_widget ( new_tab . 1 ) . set ( " " , Visibility :: Visible ) ; self . selected = index ; } }
Change the selected tab by index.
Change the selected tab by index .
&mut self
ctx
&mut Context
index
usize