cappuccino / cappuccino

Web Application Framework in JavaScript and Objective-J
https://cappuccino.dev/
GNU Lesser General Public License v2.1
2.2k stars 333 forks source link

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

Open jasperdeb opened 1 year ago

jasperdeb commented 1 year ago

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 commented 1 year ago

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

daboe01 commented 1 year ago

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

daboe01 commented 1 year ago

-#new +Aristo3

daboe01 commented 1 year ago

+#needs-info

cappbot commented 1 year ago

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

jasperdeb commented 1 year ago

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];