FLTK logo

[HIGH] STR #3523: Fl_Menu_Buttons cross over text

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.bugs  ]
 
Previous Message ]New Message | Reply ]Next Message ]

[HIGH] STR #3523: Fl_Menu_Buttons cross over text Gonzalo Garramuno May 14, 2019  
 
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: https://www.fltk.org/str.php?L3523
Version: 1.4.0


When a popup Fl_Menu_Button is popped, changes to other Fl_Menu_Buttons
effect the original popup menu button and replace its text.  So for
example, a popup with File/Open will get replaced with Red Channel from
another button.


Link: https://www.fltk.org/str.php?L3523
Version: 1.4.0

#include "FL/Fl.H"
#include "FL/Fl_Window.H"
#include "FL/Fl_Menu_Button.H"

class MyWindow;
void new_menu( MyWindow* win );

class MyWindow : public Fl_Window
{
    Fl_Menu_Button* pop1;  // first menu
    Fl_Menu_Button* pop2;  // second menu
  public:
    MyWindow(int w, int h) : Fl_Window( w, h ),
			     pop1( new Fl_Menu_Button(0,0,0,0)),
			     pop2( new Fl_Menu_Button( 30, 30, 60, 20,
						       "no image"))
    {
	pop1->type( Fl_Menu_Button::POPUP3 );
    }
    
    int handle( int e )
    {
	if ( Fl::event_button() == 3 )
	{
	    pop1->add( "File/Open/Sequence" );
	    pop1->add( "File/Save/Image" );
	    pop1->add( "Edit/Copy" );
	    pop1->add( "Next" );
	    pop1->add( "Previous" );
	    pop1->popup();
	    pop1->clear();
	    return 1;
	}
	return Fl_Window::handle( e );
    }

    void pop2_create()
    {
	pop2->clear();
	pop2->add( "Red" );
	pop2->add( "Green" );
	pop2->add( "Blue" );
	Fl::repeat_timeout( 2.0, (Fl_Timeout_Handler) new_menu, this );
    }
};

void new_menu( MyWindow* win )
{
    win->pop2_create();
}

int main( int argc, char** argv )
{
    MyWindow win(640,480);
    Fl::add_timeout( 0.5, (Fl_Timeout_Handler) new_menu, &win );
    win.show();
    return Fl::run();
}
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.