Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Button

 

Counting button clicks

 

 

 

Button.cpp

 

#include <CtrlLib/CtrlLib.h>

 

// http://java.sun.com/docs/books/tutorial/uiswing/start/swingTour.html

 

using namespace Upp;

 

struct ButtonApp : TopWindow {

    int    count;

    Button button;

    Label  label;

 

    void RefreshLabel()

    {

        label = Format("Number of button clicks %d", count);

    }

    void Click()

    {

        ++count;

        RefreshLabel();

    }

 

    typedef ButtonApp CLASSNAME;

 

    ButtonApp()

    {

        count = 0;

        button <<= THISBACK(Click);

        button.SetLabel("&I'm an U++ button!");

        Add(button.VCenterPos(20).HCenterPos(200));

        Add(label.BottomPos(0, 20).HCenterPos(200));

        label.SetAlign(ALIGN_CENTER);

        Sizeable().Zoomable();

        RefreshLabel();

    }

};

 

GUI_APP_MAIN

{

    ButtonApp().Run();

}

 

 

 

 

Do you want to contribute?