MCPcopy Create free account
hub / github.com/braitsch/ofxDatGui / onButtonEvent

Method onButtonEvent

example-Buttons/src/ofApp.cpp:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void ofApp::onButtonEvent(ofxDatGuiButtonEvent e)
39{
40// we have a couple ways to figure out which button was clicked //
41
42// we can compare our button pointer to the target of the event //
43 if (e.target == button){
44 numClicks++;
45 if (numClicks == 1){
46 button->setLabel("YOU CLICKED ME ONCE");
47 } else{
48 button->setLabel("YOU CLICKED ME "+ofToString(numClicks)+" TIMES");
49 }
50
51// or we can check against the label of the event target //
52 } else if(e.target->getLabel() == "TOGGLE FULLSCREEN"){
53 isFullscreen =!isFullscreen;
54 ofSetFullscreen(isFullscreen);
55 if (!isFullscreen) {
56 ofSetWindowShape(1920, 1080);
57 ofSetWindowPosition((ofGetScreenWidth()/2)-(1920/2), 0);
58 }
59 positionButtons();
60 }
61}
62
63void ofApp::positionButtons()
64{

Callers 2

setupMethod · 0.45
setupMethod · 0.45

Calls 2

setLabelMethod · 0.80
getLabelMethod · 0.45

Tested by

no test coverage detected