mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-30 03:48:49 +00:00
Fixed: selection did not work in Cappuccino when doing a right click or dragging
Previously, the selection of a textField did not work as expected when the user did a right click or a drag even if the label was set to none selectable. Now, with the css style user-select, a textField can only be selected if it is selectable and enable. Credit to @primalmotion
This commit is contained in:
1 parent
923d32ee6d
commit
d1e31da2e5
2 files changed
+18
No files matched your search
@@ -432,6 +432,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// We only allow first responder status if the field is enabled.
|
||||
if (!shouldBeEnabled && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
|
||||
[self _setCSSSelectionStyleForDOMElement];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -441,6 +443,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)setSelectable:(BOOL)aFlag
|
||||
{
|
||||
_isSelectable = aFlag;
|
||||
[self _setCSSSelectionStyleForDOMElement];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -700,6 +703,20 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the selection css style for the DOM element of the textField
|
||||
@ignore
|
||||
*/
|
||||
- (void)_setCSSSelectionStyleForDOMElement
|
||||
{
|
||||
#if PLATFORM (DOM)
|
||||
if (_isSelectable && [self isEnabled])
|
||||
_DOMElement.style[CPBrowserStyleProperty(@"user-select")] = @"text";
|
||||
else
|
||||
_DOMElement.style[CPBrowserStyleProperty(@"user-select")] = @"none";
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the css style for the input element of the textField
|
||||
@ignore
|
||||
|
||||
@@ -365,6 +365,7 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
|
||||
_DOMBodyElement.style["-khtml-user-select"] = "none";
|
||||
|
||||
_DOMBodyElement.webkitTouchCallout = "none";
|
||||
_DOMBodyElement.style[CPBrowserStyleProperty(@"user-select")] = @"none";
|
||||
|
||||
[self createDOMElements];
|
||||
[self _addLayers];
|
||||
|
||||
Reference in new issue
Block a user