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

A3 branch vs latest version Didier: CPButtonBar loads button twice #3051

Open
jasperdeb opened this issue Feb 10, 2023 · 6 comments
Open

A3 branch vs latest version Didier: CPButtonBar loads button twice #3051

jasperdeb opened this issue Feb 10, 2023 · 6 comments
Labels
Milestone

Comments

@jasperdeb
Copy link
Contributor

When setting the buttons in "CPButtonBar 2.0", buttons are loaded twice.

image

As described in the Wiki by Didier, buttons are loaded in with the delegate populateButtonBar. In the latest version of Didier the buttons are loaded once. In the latest master + A3 branch, items are loaded twice.

-(void)populateButtonBar:(CPButtonBar)aButtonBar
{
        var buttonTemp = [aButtonBar plusButton];
        [buttonTemp setTarget: self];
        [buttonTemp setAction:@selector(insertBorderel:)];
        [aButtonBar addButton:buttonTemp];

        buttonTemp = [aButtonBar minusButton];
        [buttonTemp setTarget: self];
        [buttonTemp setAction:@selector(removeBorderel:)];
        [aButtonBar addButton:buttonTemp];

        var imageTemp = [[CPImage alloc] initWithContentsOfFile:@"Resources/change.png" size:CGSizeMake(16, 16)];
        var newbutton = [aButtonBar buttonWithImage:imageTemp alternateImage:imageTemp]
        [newbutton setToolTip:@"Wijzig tussen initieële hoeveelheid en uitvoering"];
        [newbutton setTarget:self];
        [newbutton setAction:@selector(changeModeBorderel:)]; //newProject:
        [aButtonBar addButton:newbutton];

        var imageTemp = [[CPImage alloc] initWithContentsOfFile:@"Resources/checked.png" size:CGSizeMake(16, 16)];
        var newbutton = [aButtonBar buttonWithImage:imageTemp alternateImage:imageTemp]
        [newbutton setToolTip:@"Wijzig status nazicht"];
        [newbutton setTarget:self];
        [newbutton setAction:@selector(changeStateBorderel:)]; //newProject:
        [aButtonBar addButton:newbutton];

        var imageTemp = [[CPImage alloc] initWithContentsOfFile:@"Resources/pdf_1.png" size:CGSizeMake(16, 16)];
        var newbutton = [aButtonBar buttonWithImage:imageTemp alternateImage:imageTemp]
        [newbutton setToolTip:@"PDF"];
        [newbutton setTarget:self];
        [newbutton setAction:@selector(openBorderel:)]; //newProject:
        [aButtonBar addButton:newbutton];
}
@cappbot cappbot added this to the Someday milestone Feb 10, 2023
@cappbot cappbot added the #new label Feb 10, 2023
@cappbot
Copy link

cappbot commented Feb 10, 2023

Milestone: Someday. Label: #new. What's next? A reviewer should examine this issue.

@daboe01
Copy link
Contributor

daboe01 commented Feb 15, 2023

could you possibly add a debugger statement in your code and post screenshots of the two call stacks here?

@daboe01
Copy link
Contributor

daboe01 commented Feb 15, 2023

-#new
+Aristo3

@daboe01
Copy link
Contributor

daboe01 commented Feb 15, 2023

+#needs-info

@cappbot cappbot added #needs-info Aristo3 Theme Aristo3 and removed #new labels Feb 15, 2023
@cappbot
Copy link

cappbot commented Feb 15, 2023

Milestone: Someday. Labels: #needs-info, Aristo3. What's next? Additional information should be added as a comment to this isuse.

@jasperdeb
Copy link
Contributor Author

jasperdeb commented Feb 15, 2023

Both setStyle: and setDelegate: call for the populateButtonBar: method of CPButtonBar. If I set the style before setting the delegate, the buttons are only once loaded. If a delegate is set before the style is set, the buttons are loaded twice.

This is how the buttonbar is created by code

buttonBarDown = [[CPButtonBar alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(bounds)-500-25-25/2, CGRectGetWidth(bounds), 25)];
[buttonBarDown setStyle:CPButtonBarLegacyStyle];
[buttonBarDown setDelegate:self];
[buttonBarDown setAutoresizingMask: CPViewWidthSizable | CPViewMinYMargin];
[contentViewDown addSubview:buttonBarDown];

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

No branches or pull requests

3 participants