mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 11:40:48 +00:00
Mouse handling fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3973 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c444b09026
commit
bceff2165a
6 changed files with 148 additions and 106 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <AppKit/NSScrollView.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSTextFieldCell.h>
|
||||
#include <AppKit/PSOperators.h>
|
||||
|
||||
#define COLUMN_SEP 6
|
||||
|
||||
|
@ -1296,6 +1297,7 @@
|
|||
{
|
||||
int i;
|
||||
|
||||
NSRectClip(rect);
|
||||
// Load the first column if not already done
|
||||
if (!_isLoaded)
|
||||
{
|
||||
|
|
|
@ -47,24 +47,24 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSButton class])
|
||||
{
|
||||
[self setVersion:1];
|
||||
[self setCellClass:[NSButtonCell class]];
|
||||
[self setVersion: 1];
|
||||
[self setCellClass: [NSButtonCell class]];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Initializing the NSButton Factory
|
||||
//
|
||||
+ (Class)cellClass
|
||||
+ (Class) cellClass
|
||||
{
|
||||
return _nsbuttonCellClass;
|
||||
}
|
||||
|
||||
+ (void)setCellClass:(Class)classId
|
||||
+ (void) setCellClass: (Class)classId
|
||||
{
|
||||
_nsbuttonCellClass = classId;
|
||||
}
|
||||
|
@ -77,32 +77,37 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
- init
|
||||
{
|
||||
return [self initWithFrame:NSZeroRect];
|
||||
return [self initWithFrame: NSZeroRect];
|
||||
}
|
||||
|
||||
- initWithFrame:(NSRect)frameRect
|
||||
- initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
[super initWithFrame:frameRect];
|
||||
[super initWithFrame: frameRect];
|
||||
|
||||
// set our cell
|
||||
[self setCell:[[_nsbuttonCellClass new] autorelease]];
|
||||
[self setCell: [[_nsbuttonCellClass new] autorelease]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the Button Type
|
||||
//
|
||||
- (void)setButtonType:(NSButtonType)aType
|
||||
- (void) setButtonType: (NSButtonType)aType
|
||||
{
|
||||
[cell setButtonType:aType];
|
||||
[cell setButtonType: aType];
|
||||
[self display];
|
||||
}
|
||||
|
||||
//
|
||||
// Identifying the Selected Cell
|
||||
//
|
||||
- (id)selectedCell
|
||||
- (id) selectedCell
|
||||
{
|
||||
return cell;
|
||||
}
|
||||
|
@ -110,28 +115,28 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Setting the State
|
||||
//
|
||||
- (void)setIntValue:(int)anInt
|
||||
- (void) setIntValue: (int)anInt
|
||||
{
|
||||
[self setState:(anInt != 0)];
|
||||
[self setState: (anInt != 0)];
|
||||
}
|
||||
|
||||
- (void)setFloatValue:(float)aFloat
|
||||
- (void) setFloatValue: (float)aFloat
|
||||
{
|
||||
[self setState:(aFloat != 0)];
|
||||
[self setState: (aFloat != 0)];
|
||||
}
|
||||
|
||||
- (void)setDoubleValue:(double)aDouble
|
||||
- (void) setDoubleValue: (double)aDouble
|
||||
{
|
||||
[self setState:(aDouble != 0)];
|
||||
[self setState: (aDouble != 0)];
|
||||
}
|
||||
|
||||
- (void)setState:(int)value
|
||||
- (void) setState: (int)value
|
||||
{
|
||||
[cell setState:value];
|
||||
[cell setState: value];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (int)state
|
||||
- (int) state
|
||||
{
|
||||
return [cell state];
|
||||
}
|
||||
|
@ -139,39 +144,39 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Setting the Repeat Interval
|
||||
//
|
||||
- (void)getPeriodicDelay:(float *)delay
|
||||
interval:(float *)interval
|
||||
- (void) getPeriodicDelay: (float *)delay
|
||||
interval: (float *)interval
|
||||
{
|
||||
[cell getPeriodicDelay:delay interval:interval];
|
||||
[cell getPeriodicDelay: delay interval: interval];
|
||||
}
|
||||
|
||||
- (void)setPeriodicDelay:(float)delay
|
||||
interval:(float)interval
|
||||
- (void) setPeriodicDelay: (float)delay
|
||||
interval: (float)interval
|
||||
{
|
||||
[cell setPeriodicDelay:delay interval:interval];
|
||||
[cell setPeriodicDelay: delay interval: interval];
|
||||
}
|
||||
|
||||
//
|
||||
// Setting the Titles
|
||||
//
|
||||
- (NSString *)alternateTitle
|
||||
- (NSString *) alternateTitle
|
||||
{
|
||||
return [cell alternateTitle];
|
||||
}
|
||||
|
||||
- (void)setAlternateTitle:(NSString *)aString
|
||||
- (void) setAlternateTitle: (NSString *)aString
|
||||
{
|
||||
[cell setAlternateTitle:aString];
|
||||
[cell setAlternateTitle: aString];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (void)setTitle:(NSString *)aString
|
||||
- (void) setTitle: (NSString *)aString
|
||||
{
|
||||
[cell setTitle:aString];
|
||||
[cell setTitle: aString];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (NSString *)title
|
||||
- (NSString *) title
|
||||
{
|
||||
return [cell title];
|
||||
}
|
||||
|
@ -179,45 +184,45 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Setting the Images
|
||||
//
|
||||
- (NSImage *)alternateImage
|
||||
- (NSImage *) alternateImage
|
||||
{
|
||||
return [cell alternateImage];
|
||||
}
|
||||
|
||||
- (NSImage *)image
|
||||
- (NSImage *) image
|
||||
{
|
||||
return [cell image];
|
||||
}
|
||||
|
||||
- (NSCellImagePosition)imagePosition
|
||||
- (NSCellImagePosition) imagePosition
|
||||
{
|
||||
return [cell imagePosition];
|
||||
}
|
||||
|
||||
- (void)setAlternateImage:(NSImage *)anImage
|
||||
- (void) setAlternateImage: (NSImage *)anImage
|
||||
{
|
||||
[cell setAlternateImage:anImage];
|
||||
[cell setAlternateImage: anImage];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (void)setImage:(NSImage *)anImage
|
||||
- (void) setImage: (NSImage *)anImage
|
||||
{
|
||||
[cell setImage:anImage];
|
||||
[cell setImage: anImage];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (void)setImagePosition:(NSCellImagePosition)aPosition
|
||||
- (void) setImagePosition: (NSCellImagePosition)aPosition
|
||||
{
|
||||
[cell setImagePosition:aPosition];
|
||||
[cell setImagePosition: aPosition];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (void)setAlignment:(NSTextAlignment)mode
|
||||
- (void) setAlignment: (NSTextAlignment)mode
|
||||
{
|
||||
[cell setAlignment:mode];
|
||||
[cell setAlignment: mode];
|
||||
}
|
||||
|
||||
- (NSTextAlignment)alignment
|
||||
- (NSTextAlignment) alignment
|
||||
{
|
||||
return [cell alignment];
|
||||
}
|
||||
|
@ -225,37 +230,37 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Modifying Graphic Attributes
|
||||
//
|
||||
- (BOOL)isBordered
|
||||
- (BOOL) isBordered
|
||||
{
|
||||
return [cell isBordered];
|
||||
}
|
||||
|
||||
- (BOOL)isTransparent
|
||||
- (BOOL) isTransparent
|
||||
{
|
||||
return [cell isTransparent];
|
||||
}
|
||||
|
||||
- (void)setBordered:(BOOL)flag
|
||||
- (void) setBordered: (BOOL)flag
|
||||
{
|
||||
[cell setBordered:flag];
|
||||
[cell setBordered: flag];
|
||||
[self display];
|
||||
}
|
||||
|
||||
- (void)setTransparent:(BOOL)flag
|
||||
- (void) setTransparent: (BOOL)flag
|
||||
{
|
||||
[cell setTransparent:flag];
|
||||
[cell setTransparent: flag];
|
||||
[self display];
|
||||
}
|
||||
|
||||
//
|
||||
// Displaying
|
||||
//
|
||||
- (void)drawRect:(NSRect)rect
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
[cell drawWithFrame:rect inView:self];
|
||||
[cell drawWithFrame: rect inView: self];
|
||||
}
|
||||
|
||||
- (void)highlight:(BOOL)flag
|
||||
- (void) highlight: (BOOL)flag
|
||||
{
|
||||
[cell highlight: flag withFrame: bounds inView: self];
|
||||
}
|
||||
|
@ -286,7 +291,7 @@ id _nsbuttonCellClass = nil;
|
|||
//
|
||||
// Determining the first responder
|
||||
//
|
||||
- (BOOL)acceptsFirstResponder
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
return [cell acceptsFirstResponder] || ([self keyEquivalent] != nil);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,11 @@
|
|||
// Class variables
|
||||
static NSFont* menuFont = nil;
|
||||
|
||||
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)rect
|
||||
{
|
||||
[super initWithFrame: rect];
|
||||
|
|
|
@ -88,6 +88,11 @@ static BOOL preCalcValues = NO;
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSScrollArrowPosition) arrowsPosition
|
||||
{
|
||||
return _arrowsPosition;
|
||||
|
|
|
@ -45,6 +45,11 @@
|
|||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
|
|
|
@ -1142,6 +1142,7 @@
|
|||
- (void) sendEvent: (NSEvent *)theEvent
|
||||
{
|
||||
NSView *v;
|
||||
NSEventType type;
|
||||
|
||||
if (!cursor_rects_valid) // If the cursor rects are invalid
|
||||
{ // Then discard and reset
|
||||
|
@ -1149,14 +1150,18 @@
|
|||
[self resetCursorRects];
|
||||
}
|
||||
|
||||
switch ([theEvent type])
|
||||
type = [theEvent type];
|
||||
switch (type)
|
||||
{
|
||||
case NSLeftMouseDown: // Left mouse down
|
||||
v = [content_view hitTest: [theEvent locationInWindow]];
|
||||
NSDebugLog([v description]);
|
||||
NSDebugLog(@"\n");
|
||||
if (first_responder != v) // if hit view is not first
|
||||
[self makeFirstResponder: v]; // responder ask it to be
|
||||
if (first_responder != v)
|
||||
{
|
||||
[self makeFirstResponder: v];
|
||||
if ([v acceptsFirstMouse: theEvent] == YES)
|
||||
[v mouseDown: theEvent];
|
||||
}
|
||||
else
|
||||
[v mouseDown: theEvent];
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
@ -1179,28 +1184,43 @@
|
|||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
||||
case NSMouseMoved: // Mouse moved
|
||||
v = [content_view hitTest: [theEvent locationInWindow]];
|
||||
[v mouseMoved: theEvent]; // First send the NSMouseMoved event
|
||||
// We need to go through all of the views, and any with
|
||||
// a tracking rectangle then we need to determine if we
|
||||
// should send a NSMouseEntered or NSMouseExited event
|
||||
[self checkTrackingRectangles: content_view forEvent: theEvent];
|
||||
// We need to go through all of the views, and any with
|
||||
// a cursor rectangle then we need to determine if we
|
||||
// should send a cursor update event
|
||||
// We only do this if we are the key window
|
||||
if (is_key)
|
||||
[self checkCursorRectangles: content_view forEvent: theEvent];
|
||||
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
||||
case NSLeftMouseDragged: // Left mouse dragged
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
||||
case NSRightMouseDragged: // Right mouse dragged
|
||||
case NSMouseMoved: // Mouse moved
|
||||
switch (type)
|
||||
{
|
||||
case NSLeftMouseDragged:
|
||||
v = [content_view hitTest: [theEvent locationInWindow]];
|
||||
[v mouseDragged: theEvent];
|
||||
break;
|
||||
case NSRightMouseDragged:
|
||||
v = [content_view hitTest: [theEvent locationInWindow]];
|
||||
[v rightMouseDragged: theEvent];
|
||||
break;
|
||||
default:
|
||||
if (accepts_mouse_moved)
|
||||
{
|
||||
// If the window is set to accept mouse movements, we need to
|
||||
// forward the mouse movement to the correct view.
|
||||
v = [content_view hitTest: [theEvent locationInWindow]];
|
||||
[v mouseMoved: theEvent];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// We need to go through all of the views, and if there is any with
|
||||
// a tracking rectangle then we need to determine if we should send
|
||||
// a NSMouseEntered or NSMouseExited event.
|
||||
[self checkTrackingRectangles: content_view forEvent: theEvent];
|
||||
|
||||
if (is_key)
|
||||
{
|
||||
// We need to go through all of the views, and if there is any with
|
||||
// a cursor rectangle then we need to determine if we should send a
|
||||
// cursor update event.
|
||||
[self checkCursorRectangles: content_view forEvent: theEvent];
|
||||
}
|
||||
|
||||
last_point = [theEvent locationInWindow];
|
||||
break;
|
||||
|
||||
|
@ -1642,7 +1662,7 @@
|
|||
disable_flush_window = NO;
|
||||
menu_exclude = NO;
|
||||
hides_on_deactivate = NO;
|
||||
accepts_mouse_moved = YES;
|
||||
accepts_mouse_moved = NO;
|
||||
}
|
||||
|
||||
- (id) cleanInit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue