Fixed the SyncEnableState() machinery not quite working properly.
This commit is contained in:
parent
7b0780be2a
commit
d7d7d4fd76
|
@ -70,6 +70,8 @@ static void uiBoxSyncEnableState(uiDarwinControl *c, int enabled)
|
||||||
uiBox *b = uiBox(c);
|
uiBox *b = uiBox(c);
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
|
|
||||||
|
if (uiDarwinShouldStopSyncEnableState(uiDarwinControl(b), enabled))
|
||||||
|
return;
|
||||||
for (i = 0; i < [b->children count]; i++) {
|
for (i = 0; i < [b->children count]; i++) {
|
||||||
NSValue *v;
|
NSValue *v;
|
||||||
uiControl *child;
|
uiControl *child;
|
||||||
|
|
|
@ -22,3 +22,15 @@ uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *ty
|
||||||
{
|
{
|
||||||
return uiDarwinControl(uiAllocControl(n, uiDarwinControlSignature, typesig, typenamestr));
|
return uiDarwinControl(uiAllocControl(n, uiDarwinControlSignature, typesig, typenamestr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *c, BOOL enabled)
|
||||||
|
{
|
||||||
|
int ce;
|
||||||
|
|
||||||
|
ce = uiControlEnabled(uiControl(c));
|
||||||
|
// only stop if we're going from disabled back to enabled; don't stop under any other condition
|
||||||
|
// (if we stop when going from enabled to disabled then enabled children of a disabled control won't get disabled at the OS level)
|
||||||
|
if (!ce && enabled)
|
||||||
|
return YES;
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ static void uiGroupSyncEnableState(uiDarwinControl *c, int enabled)
|
||||||
{
|
{
|
||||||
uiGroup *g = uiGroup(c);
|
uiGroup *g = uiGroup(c);
|
||||||
|
|
||||||
|
if (uiDarwinShouldStopSyncEnableState(uiDarwinControl(g), enabled))
|
||||||
|
return;
|
||||||
if (g->child != NULL)
|
if (g->child != NULL)
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(g->child), enabled);
|
uiDarwinControlSyncEnableState(uiDarwinControl(g->child), enabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,8 @@ static void uiWindowSyncEnableState(uiDarwinControl *c, int enabled)
|
||||||
{
|
{
|
||||||
uiWindow *w = uiWindow(c);
|
uiWindow *w = uiWindow(c);
|
||||||
|
|
||||||
|
if (uiDarwinShouldStopSyncEnableState(uiDarwinControl(w), enabled))
|
||||||
|
return;
|
||||||
if (w->child != NULL)
|
if (w->child != NULL)
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(w->child), enabled);
|
uiDarwinControlSyncEnableState(uiDarwinControl(w->child), enabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *);
|
||||||
#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \
|
#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \
|
||||||
static void type ## SyncEnableState(uiDarwinControl *c, int enabled) \
|
static void type ## SyncEnableState(uiDarwinControl *c, int enabled) \
|
||||||
{ \
|
{ \
|
||||||
|
if (uiDarwinShouldStopSyncEnableState(c, enabled)) \
|
||||||
|
return; \
|
||||||
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \
|
||||||
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
[((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \
|
||||||
}
|
}
|
||||||
|
@ -148,6 +150,9 @@ _UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size);
|
||||||
// You can use this function from within your control implementations to return text strings that can be freed with uiFreeText().
|
// You can use this function from within your control implementations to return text strings that can be freed with uiFreeText().
|
||||||
_UI_EXTERN char *uiDarwinNSStringToText(NSString *);
|
_UI_EXTERN char *uiDarwinNSStringToText(NSString *);
|
||||||
|
|
||||||
|
// TODO document
|
||||||
|
_UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue