development version (master branch)
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 = 0;

    Button button;

    Label  label;

 

    void RefreshLabel()

    {

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

    }

 

    ButtonApp()

    {

        Title("Button example");

        button << [=] { ++count; RefreshLabel(); };

        button.SetLabel("Click me!");

        Add(button.VCenterPosZ(30).HCenterPosZ(200));

        Add(label.BottomPosZ(0, 20).HCenterPosZ(200));

        label.SetAlign(ALIGN_CENTER);

        Sizeable().Zoomable();

        RefreshLabel();

    }

};

 

GUI_APP_MAIN

{

    ButtonApp().Run();

}

 

 

 

 

Do you want to contribute?