Implemented enabling/disabling on uiArea on OS X.
This commit is contained in:
parent
4c98fda7ff
commit
3d9d782db3
|
@ -1,12 +1,11 @@
|
||||||
// 9 september 2015
|
// 9 september 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODO implement setEnabled:
|
|
||||||
|
|
||||||
@interface areaView : NSView {
|
@interface areaView : NSView {
|
||||||
uiArea *libui_a;
|
uiArea *libui_a;
|
||||||
NSTrackingArea *libui_ta;
|
NSTrackingArea *libui_ta;
|
||||||
NSSize libui_ss;
|
NSSize libui_ss;
|
||||||
|
BOOL libui_enabled;
|
||||||
}
|
}
|
||||||
- (id)initWithFrame:(NSRect)r area:(uiArea *)a;
|
- (id)initWithFrame:(NSRect)r area:(uiArea *)a;
|
||||||
- (uiModifiers)parseModifiers:(NSEvent *)e;
|
- (uiModifiers)parseModifiers:(NSEvent *)e;
|
||||||
|
@ -18,6 +17,8 @@
|
||||||
- (int)doFlagsChanged:(NSEvent *)e;
|
- (int)doFlagsChanged:(NSEvent *)e;
|
||||||
- (void)setupNewTrackingArea;
|
- (void)setupNewTrackingArea;
|
||||||
- (void)setScrollingSize:(NSSize)s;
|
- (void)setScrollingSize:(NSSize)s;
|
||||||
|
- (BOOL)isEnabled;
|
||||||
|
- (void)setEnabled:(BOOL)e;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
struct uiArea {
|
struct uiArea {
|
||||||
|
@ -195,7 +196,8 @@ struct uiArea {
|
||||||
me.Held1To64 |= j;
|
me.Held1To64 |= j;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*(a->ah->MouseEvent))(a->ah, a, &me);
|
if (self->libui_enabled)
|
||||||
|
(*(a->ah->MouseEvent))(a->ah, a, &me);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define mouseEvent(name) \
|
#define mouseEvent(name) \
|
||||||
|
@ -218,14 +220,16 @@ mouseEvent(otherMouseUp)
|
||||||
{
|
{
|
||||||
uiArea *a = self->libui_a;
|
uiArea *a = self->libui_a;
|
||||||
|
|
||||||
(*(a->ah->MouseCrossed))(a->ah, a, 0);
|
if (self->libui_enabled)
|
||||||
|
(*(a->ah->MouseCrossed))(a->ah, a, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseExited:(NSEvent *)e
|
- (void)mouseExited:(NSEvent *)e
|
||||||
{
|
{
|
||||||
uiArea *a = self->libui_a;
|
uiArea *a = self->libui_a;
|
||||||
|
|
||||||
(*(a->ah->MouseCrossed))(a->ah, a, 1);
|
if (self->libui_enabled)
|
||||||
|
(*(a->ah->MouseCrossed))(a->ah, a, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: there is no equivalent to WM_CAPTURECHANGED on Mac OS X; there literally is no way to break a grab like that
|
// note: there is no equivalent to WM_CAPTURECHANGED on Mac OS X; there literally is no way to break a grab like that
|
||||||
|
@ -309,6 +313,24 @@ mouseEvent(otherMouseUp)
|
||||||
return self->libui_ss;
|
return self->libui_ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)becomeFirstResponder
|
||||||
|
{
|
||||||
|
return [self isEnabled];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEnabled
|
||||||
|
{
|
||||||
|
return self->libui_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEnabled:(BOOL)e
|
||||||
|
{
|
||||||
|
self->libui_enabled = e;
|
||||||
|
if (!self->libui_enabled && [self window] != nil)
|
||||||
|
if ([[self window] firstResponder] == self)
|
||||||
|
[[self window] makeFirstResponder:nil];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
uiDarwinControlAllDefaultsExceptDestroy(uiArea, view)
|
uiDarwinControlAllDefaultsExceptDestroy(uiArea, view)
|
||||||
|
|
Loading…
Reference in New Issue