Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request & example of code #63

Open
Taprik opened this issue Nov 6, 2017 · 1 comment
Open

feature request & example of code #63

Taprik opened this issue Nov 6, 2017 · 1 comment

Comments

@Taprik
Copy link

Taprik commented Nov 6, 2017

Dear Frauzufall,

Again, many thanks for this impressive addon.
It's the second time I'm using it. Now this is for a big project and it's really working 👍

There is a feature I'd like : to be warn when the load or save button in the header of a panel are pressed.
I've make it this way (don't know if it's correct) :
In ofxGuiPanelHeader class I add

       ofParameter<bool> loadisPressed;
	ofParameter<bool> saveisPressed;

In ofxGuiPanel class I add

     ofxGuiPanelHeader* getPanelHeader();

the function is

   ofxGuiPanelHeader* ofxGuiPanel::getPanelHeader() {
return (ofxGuiPanelHeader*)header;
  }

in the constructor of ofxGuiPanelHeader I add

     loadisPressed.set("load button", false);
   saveisPressed.set("save button", false);

The moussePressed function was changed this way

    bool ofxGuiPanelHeader::mousePressed(ofMouseEventArgs & args){

if(!isHidden()){
	ofPoint pos = screenToLocal(ofPoint(args.x, args.y));
	if(loadBox.inside(pos)){
		ofNotifyEvent(loadPressedE,this);
		loadisPressed.set(true);
		return true;
	}
	if(saveBox.inside(pos)) {
		ofNotifyEvent(savePressedE,this);
		saveisPressed.set(true);
		return true;
	}

}

return ofxGuiElement::mousePressed(args);
}

Then I add listener to this ofParameter in my code.

Tell me if you need a pull request.
Cheers

@Taprik
Copy link
Author

Taprik commented Jun 15, 2018

Dear Frauzufall,
Actually you can close this issue as I manage to do that with a ofAddListener. It's simpler this way.
For example
ofAddListener(((ofxGuiPanelHeader*)Panel->getHeader())->savePressedE, this, &ofApp::saveSettings);
where Panel is a ofxGuiPanel.
Cheers (and thanks again)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant