Skip to content
James Bremner edited this page Oct 29, 2019 · 3 revisions

When user clicks on a widget ( presses the left mouse button ) the widget runs some default code.

Applications will often need other code to run when a widget is clicked. This can be arranged by registering a click event handler.

    // display a button
    wex::button& btn = wex::make<button>( form );
    btn.move( {20, 250, 150, 30 } );
    btn.text( "Do something" );

    // register click event handler
    btn.events().click([&]
    {

         ... code to run when button clicked ...
    });

Methods

click

void click( std::function<void(void)> f, bool propogate = false )

register click event handler. specify that click event should propogate to parent window after processing, default is false

draw

void draw( std::function<void(PAINTSTRUCT& ps)> f )

resize

void resize( std::function<void(int w, int h)> f )

scrollH

void scrollH( std::function<void(int code)> f )

scrollV

void scrollV( std::function<void(int code)> f )

menu

/** Register function to run when menu item clicked
    @param[in] id
    @param[in] f function to run when menu item with id is clicked
*/
void menuCommand( int id, std::function<void(void)> f )

mouseMove

void mouseMove( std::function<void(sMouse& m)> f )

Register function to run when the mouse moves.

struct  sMouse
{
    int x;
    int y;
    bool left;
};
Clone this wiki locally