Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di Aki
    Registrato dal
    Dec 2002
    Messaggi
    2,206

    [C++] FLTK: Scatenare un evento

    Ave populus
    ho questo codice:
    codice:
    #include <FL/Fl.H>
    #include <FL/Fl_Window.H>
    #include <FL/Fl_Box.H>
    #include <FL/Fl_Input.H>
    #include <FL/Fl_Return_Button.H>
    
    int main (int argc, char ** argv)
    {
      Fl_Window *window;
      Fl_Box *box;
      Fl_Input *txt;
      Fl_Return_Button *btn;
    
      window = new Fl_Window (240, 130);
      window->color(FL_CYAN);
      
      txt = new Fl_Input(20, 10, 200, 30, "");
      txt->box(FL_DOWN_BOX);
      txt->labelsize(12);
      
      btn = new Fl_Return_Button(20,50,200,30,"Premi qui");
      btn->labelfont(FL_BOLD);
      btn->color(FL_BLUE);  
      btn->labelcolor(FL_YELLOW);
      btn->box(FL_PLASTIC_UP_BOX);
      btn->labelsize(16);
      
      box = new Fl_Box (20, 90, 200, 30, "");
      box->box (FL_NO_BOX);
      box->labelcolor(FL_BLUE);
      box->labelsize (16);
      
      window->end ();
      window->show (argc, argv);
    
      return(Fl::run());
    }
    come faccio a far eseguire una azione alla pressione del tasto??

  2. #2
    Utente di HTML.it L'avatar di Aki
    Registrato dal
    Dec 2002
    Messaggi
    2,206

    Re: [C++] FLTK: Scatenare un evento


  3. #3
    Utente di HTML.it L'avatar di Aki
    Registrato dal
    Dec 2002
    Messaggi
    2,206

    Re: [C++] FLTK: Scatenare un evento

    ho provato anche così:
    codice:
    #include <FL/Fl.H>
    #include <FL/Fl_Window.H>
    #include <FL/Fl_Output.H>
    #include <FL/Fl_Input.H>
    #include <FL/Fl_Return_Button.H>
    
    int scrivi(*box)
    {
      box->value("CIAO");
    }
    
    int main(int argc, char ** argv)
    {
      Fl_Window *window;
      Fl_Input *txt;
      Fl_Output *box;
      Fl_Return_Button *btn;
    
      window = new Fl_Window (240, 130, "FLTK_develop");
      window->color(FL_CYAN);
      
      txt = new Fl_Input(20, 10, 200, 30, "");
      txt->box(FL_DOWN_BOX);
      txt->labelsize(12);
      
      btn = new Fl_Return_Button(20,50,200,30,"Premi qui");
      btn->labelfont(FL_BOLD);
      btn->color(FL_BLUE);  
      btn->labelcolor(FL_YELLOW);
      btn->box(FL_PLASTIC_UP_BOX);
      btn->labelsize(16);
      
      box = new Fl_Output (190, 90, 200, 30, "<<< UNKNOWN >>>");
      box->box (FL_NO_BOX);
      box->labelcolor(FL_BLUE);
      box->labelsize (16);
      
      btn->when(FL_WHEN_RELEASE);
      btn->callback(scrivi, *box);
      
      window->end ();
      window->show ();
      return(Fl::run());  
    }
    richiamando la funzione scrivi e passandogli il puntatore al Widget di Output, ma nulla, non và ancora

  4. #4
    Utente di HTML.it L'avatar di Aki
    Registrato dal
    Dec 2002
    Messaggi
    2,206
    ora ho scritto questo:
    codice:
    #include <FL/Fl.H>
    #include <FL/Fl_Window.H>
    #include <FL/Fl_Output.H>
    #include <FL/Fl_Input.H>
    #include <FL/Fl_Return_Button.H>
    
    void xyz_callback(Fl_Widget *w, void *data)
    {
      char *str;
      str = "CIAO";
      w->label(str);
    }
    
    int main(int argc, char ** argv)
    {
      Fl_Window *window;
      Fl_Input *txt;
      Fl_Output *box;
      Fl_Return_Button *btn;
      int xyz_data;
    
      window = new Fl_Window (240, 130, "FLTK_develop");
      window->color(FL_CYAN);
      
      txt = new Fl_Input(20, 10, 200, 30, "");
      txt->box(FL_DOWN_BOX);
      txt->labelsize(12);
      
      btn = new Fl_Return_Button(20,50,200,30,"Premi qui");
      btn->labelfont(FL_BOLD);
      btn->color(FL_BLUE);  
      btn->labelcolor(FL_YELLOW);
      btn->box(FL_PLASTIC_UP_BOX);
      btn->labelsize(16);
      
      box = new Fl_Output (190, 90, 200, 30, "<<< UNKNOWN >>>");
      box->box (FL_NO_BOX);
      box->labelcolor(FL_BLUE);
      box->labelsize (16);
    
      btn->callback(xyz_callback,&xyz_data);
      
      window->end ();
      window->show ();
      return(Fl::run());  
    }
    così riesco a scrivere la stringa str come testo del button, ma non riesco a comandare gli altri 2 widget, in particolare il widget di output, che è quello su cui mi interessa scrivere la stringa

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.