mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Fixed: deviation from cocoa when calling setTitle:'' (#2607)
This commit is contained in:
+10
-2
@@ -491,9 +491,17 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
[self addItemWithTitle:aTitle];
|
||||
|
||||
index = [self numberOfItems] - 1;
|
||||
// this ist to match cocoa where setting an empty string does not add it but simply clears the title
|
||||
// and sets objectValue to -1
|
||||
if (aTitle === '')
|
||||
[self selectItemAtIndex:-1];
|
||||
else
|
||||
{
|
||||
[self addItemWithTitle:aTitle];
|
||||
|
||||
index = [self numberOfItems] - 1;
|
||||
}
|
||||
}
|
||||
|
||||
[self selectItemAtIndex:index];
|
||||
|
||||
@@ -75,9 +75,24 @@
|
||||
// https://github.com/280north/cappuccino/pull/1018
|
||||
[popUpButton2 selectItemWithTag:2];
|
||||
|
||||
// manual test for https://github.com/cappuccino/cappuccino/issues/2471
|
||||
var button2 = [CPButton buttonWithTitle:@"Set title to: ''"];
|
||||
|
||||
[button2 setCenter:CGPointMake([contentView center].x, 0)];
|
||||
[button2 setFrameOrigin:CGPointMake(CGRectGetMinX([button frame]), CGRectGetMaxY([button frame]) + 20)];
|
||||
[button2 setTarget:self];
|
||||
[button2 setAction:@selector(setTitleToEmptyString:)];
|
||||
[contentView addSubview:button2];
|
||||
|
||||
|
||||
[theWindow orderFront:self];
|
||||
}
|
||||
|
||||
- (@action)setTitleToEmptyString:(id)sender
|
||||
{
|
||||
[popUpButton setTitle:''];
|
||||
}
|
||||
|
||||
- (@action)removeItems:(id)sender
|
||||
{
|
||||
[popUpButton2 removeAllItems];
|
||||
|
||||
Reference in New Issue
Block a user