mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-05 02:13:40 +00:00
Fix for drag and drop with platform windows.
Reviewed by me.
This commit is contained in:
@@ -252,8 +252,9 @@ var CPDragServerUpdateDragging = function(anEvent)
|
||||
#if PLATFORM(BROWSER)
|
||||
var platformWindow = [aWindow platformWindow];
|
||||
|
||||
// FIXME: We should just have the window be the size of the view and move the window around.
|
||||
[_dragWindow setPlatformWindow:platformWindow];
|
||||
[_dragWindow setFrameSize:[platformWindow contentBounds]];
|
||||
[_dragWindow setFrameSize:[platformWindow contentBounds].size];
|
||||
#endif
|
||||
|
||||
[_dragWindow orderFront:self];
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "CPDOMWindowBridge.j"
|
||||
@import "CPFlashMovie.j"
|
||||
@import "CPView.j"
|
||||
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
*/
|
||||
@@ -96,17 +96,17 @@
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -5,12 +5,37 @@
|
||||
#import "../CoreGraphics/CGGeometry.h"
|
||||
|
||||
|
||||
var PlatformWindowClass = NULL,
|
||||
PrimaryPlatformWindow = NULL;
|
||||
var PrimaryPlatformWindow = NULL;
|
||||
|
||||
@implementation CPPlatformWindow : CPObject
|
||||
{
|
||||
CGRect _contentRect;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
DOMWindow _DOMWindow;
|
||||
|
||||
DOMElement _DOMBodyElement;
|
||||
DOMElement _DOMFocusElement;
|
||||
|
||||
CPArray _windowLevels;
|
||||
CPDictionary _windowLayers;
|
||||
|
||||
BOOL _mouseIsDown;
|
||||
CPWindow _mouseDownWindow;
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
|
||||
Object _charCodes;
|
||||
unsigned _keyCode;
|
||||
|
||||
BOOL _DOMEventMode;
|
||||
|
||||
// Native Pasteboard Support
|
||||
DOMElement _DOMPasteboardElement;
|
||||
CPEvent _pasteboardKeyDownEvent;
|
||||
|
||||
CPString _overriddenEventType;
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (CPPlatformWindow)primaryPlatformWindow
|
||||
@@ -22,41 +47,23 @@ var PlatformWindowClass = NULL,
|
||||
{
|
||||
PrimaryPlatformWindow = aPlatformWindow;
|
||||
}
|
||||
/*
|
||||
+ (BOOL)supportsMultipleWindows
|
||||
{
|
||||
#if PLATFORM(BROWSER)
|
||||
return YES;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
+ (void)_setPlatformWindowClass:(Class)aClass
|
||||
{
|
||||
PlatformWindowClass = aClass;
|
||||
}
|
||||
|
||||
+ (Class)_platformWindowClass
|
||||
{
|
||||
return PlatformWindowClass;
|
||||
}
|
||||
|
||||
+ (id)alloc
|
||||
{
|
||||
if (self === [CPPlatformWindow class])
|
||||
return [PlatformWindowClass alloc];
|
||||
|
||||
return [super alloc];
|
||||
}
|
||||
|
||||
- (id)initWithContentRect:(CGRect)aRect
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_contentRect = _CGRectMakeCopy(aRect);
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
_windowLevels = [];
|
||||
_windowLayers = [CPDictionary dictionary];
|
||||
|
||||
_charCodes = {};
|
||||
#endif
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -137,19 +144,25 @@ var PlatformWindowClass = NULL,
|
||||
{
|
||||
[self setContentRect:[self nativeContentRect]];
|
||||
}
|
||||
|
||||
/*
|
||||
- (BOOL)isVisible
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
return _DOMWindow !== NULL;
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
+ (BOOL)supportsMultipleWindows
|
||||
{
|
||||
#if PLATFORM(BROWSER)
|
||||
return YES;
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
#if PLATFORM(BROWSER)
|
||||
@import "_CPBrowserWindow.j"
|
||||
#else
|
||||
[CPPlatformWindow _setPlatformWindowClass:[CPPlatformWindow class]];
|
||||
@import "CPPlatformWindow+DOM.j"
|
||||
#endif
|
||||
|
||||
@@ -70,32 +70,7 @@ var KeyCodesToPrevent = {},
|
||||
|
||||
var CTRL_KEY_CODE = 17;
|
||||
|
||||
@implementation _CPDOMWindow : CPPlatformWindow
|
||||
{
|
||||
DOMWindow _DOMWindow;
|
||||
|
||||
DOMElement _DOMBodyElement;
|
||||
DOMElement _DOMFocusElement;
|
||||
|
||||
CPArray _windowLevels;
|
||||
CPDictionary _windowLayers;
|
||||
|
||||
BOOL _mouseIsDown;
|
||||
CPWindow _mouseDownWindow;
|
||||
CPTimeInterval _lastMouseUp;
|
||||
CPTimeInterval _lastMouseDown;
|
||||
|
||||
JSObject _charCodes;
|
||||
unsigned _keyCode;
|
||||
|
||||
BOOL _DOMEventMode;
|
||||
|
||||
// Native Pasteboard Support
|
||||
DOMElement _DOMPasteboardElement;
|
||||
CPEvent _pasteboardKeyDownEvent;
|
||||
|
||||
CPString _overriddenEventType;
|
||||
}
|
||||
@implementation CPPlatformWindow (DOM)
|
||||
|
||||
- (id)_init
|
||||
{
|
||||
@@ -104,6 +79,7 @@ var CTRL_KEY_CODE = 17;
|
||||
if (self)
|
||||
{
|
||||
_DOMWindow = window;
|
||||
_contentRect = _CGRectMakeZero();
|
||||
|
||||
[self registerDOMWindow];
|
||||
[self updateFromNativeContentRect];
|
||||
@@ -117,21 +93,6 @@ var CTRL_KEY_CODE = 17;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithContentRect:(CGRect)aRect
|
||||
{
|
||||
self = [super initWithContentRect:aRect];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_windowLevels = [];
|
||||
_windowLayers = [CPDictionary dictionary];
|
||||
|
||||
_charCodes = {};
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGRect)nativeContentRect
|
||||
{
|
||||
if (!_DOMWindow)
|
||||
@@ -333,6 +294,11 @@ var CTRL_KEY_CODE = 17;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isVisible
|
||||
{
|
||||
return _DOMWindow !== NULL;
|
||||
}
|
||||
|
||||
- (void)orderFront:(id)aSender
|
||||
{
|
||||
if (_DOMWindow)
|
||||
@@ -918,7 +884,7 @@ var CTRL_KEY_CODE = 17;
|
||||
|
||||
@param characters a list of characters to stop propagating keypresses to the browser.
|
||||
*/
|
||||
- (void)preventCharacterKeysFromPropagating:(CPArray)characters
|
||||
+ (void)preventCharacterKeysFromPropagating:(CPArray)characters
|
||||
{
|
||||
for(var i=characters.length; i>0; i--)
|
||||
CharacterKeysToPrevent[""+characters[i-1].toLowerCase()] = YES;
|
||||
@@ -927,7 +893,7 @@ var CTRL_KEY_CODE = 17;
|
||||
/*!
|
||||
@param character a character to stop propagating keypresses to the browser.
|
||||
*/
|
||||
- (void)preventCharacterKeyFromPropagating:(CPString)character
|
||||
+ (void)preventCharacterKeyFromPropagating:(CPString)character
|
||||
{
|
||||
CharacterKeysToPrevent[character.toLowerCase()] = YES;
|
||||
}
|
||||
@@ -935,7 +901,7 @@ var CTRL_KEY_CODE = 17;
|
||||
/*!
|
||||
Clear the list of characters for which we are not sending keypresses to the browser.
|
||||
*/
|
||||
- (void)clearCharacterKeysToPreventFromPropagating
|
||||
+ (void)clearCharacterKeysToPreventFromPropagating
|
||||
{
|
||||
CharacterKeysToPrevent = {};
|
||||
}
|
||||
@@ -944,7 +910,7 @@ var CTRL_KEY_CODE = 17;
|
||||
Prevent these keyCodes from sending their keypresses to the browser.
|
||||
@param keyCodes an array of keycodes to prevent propagation.
|
||||
*/
|
||||
- (void)preventKeyCodesFromPropagating:(CPArray)keyCodes
|
||||
+ (void)preventKeyCodesFromPropagating:(CPArray)keyCodes
|
||||
{
|
||||
for(var i=keyCodes.length; i>0; i--)
|
||||
KeyCodesToPrevent[keyCodes[i-1]] = YES;
|
||||
@@ -954,7 +920,7 @@ var CTRL_KEY_CODE = 17;
|
||||
Prevent this keyCode from sending its key events to the browser.
|
||||
@param keyCode a keycode to prevent propagation.
|
||||
*/
|
||||
- (void)preventKeyCodeFromPropagating:(CPString)keyCode
|
||||
+ (void)preventKeyCodeFromPropagating:(CPString)keyCode
|
||||
{
|
||||
KeyCodesToPrevent[keyCode] = YES;
|
||||
}
|
||||
@@ -962,12 +928,11 @@ var CTRL_KEY_CODE = 17;
|
||||
/*!
|
||||
Clear the list of keyCodes for which we are not sending keypresses to the browser.
|
||||
*/
|
||||
- (void)clearKeyCodesToPreventFromPropagating
|
||||
+ (void)clearKeyCodesToPreventFromPropagating
|
||||
{
|
||||
KeyCodesToPrevent = {};
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
var CPEventClass = [CPEvent class];
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
@import "_CPDOMWindow.j"
|
||||
|
||||
|
||||
@implementation _CPBrowserWindow : _CPDOMWindow
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
[CPPlatformWindow _setPlatformWindowClass:[_CPBrowserWindow class]];
|
||||
Reference in New Issue
Block a user