* The default drag&drop action is now copy, if you drag with the second mouse
button, you switch the keys. * Switching the same key with different modifiers held works now. * The drop target is now reevaluated when a modifier key is pressed, as the key originating the drag cannot be its target (but only with the same modifiers pressed). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29704 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -126,6 +126,7 @@ KeyboardLayoutView::MouseDown(BPoint point)
|
|||||||
{
|
{
|
||||||
fClickPoint = point;
|
fClickPoint = point;
|
||||||
fDragKey = NULL;
|
fDragKey = NULL;
|
||||||
|
fDropPoint.x = -1;
|
||||||
|
|
||||||
Key* key = _KeyAt(point);
|
Key* key = _KeyAt(point);
|
||||||
if (key != NULL) {
|
if (key != NULL) {
|
||||||
@@ -165,14 +166,9 @@ KeyboardLayoutView::MouseMoved(BPoint point, uint32 transit,
|
|||||||
|
|
||||||
if (dragMessage != NULL) {
|
if (dragMessage != NULL) {
|
||||||
_InvalidateKey(fDropTarget);
|
_InvalidateKey(fDropTarget);
|
||||||
|
fDropPoint = point;
|
||||||
|
|
||||||
fDropTarget = _KeyAt(point);
|
_EvaluateDropTarget(point);
|
||||||
if (fDropTarget != NULL) {
|
|
||||||
if (fDropTarget == fDragKey)
|
|
||||||
fDropTarget = NULL;
|
|
||||||
else
|
|
||||||
_InvalidateKey(fDropTarget);
|
|
||||||
}
|
|
||||||
} else if (fDragKey == NULL && (fabs(point.x - fClickPoint.x) > 4
|
} else if (fDragKey == NULL && (fabs(point.x - fClickPoint.x) > 4
|
||||||
|| fabs(point.y - fClickPoint.y) > 4)) {
|
|| fabs(point.y - fClickPoint.y) > 4)) {
|
||||||
// start dragging
|
// start dragging
|
||||||
@@ -220,6 +216,7 @@ KeyboardLayoutView::MouseMoved(BPoint point, uint32 transit,
|
|||||||
|
|
||||||
DragMessage(&drag, bitmap, B_OP_ALPHA, offset);
|
DragMessage(&drag, bitmap, B_OP_ALPHA, offset);
|
||||||
fDragKey = key;
|
fDragKey = key;
|
||||||
|
fDragModifiers = fModifiers;
|
||||||
|
|
||||||
fKeyState[key->code / 8] &= ~(1 << (7 - (key->code & 7)));
|
fKeyState[key->code / 8] &= ~(1 << (7 - (key->code & 7)));
|
||||||
_InvalidateKey(key);
|
_InvalidateKey(key);
|
||||||
@@ -252,11 +249,15 @@ KeyboardLayoutView::MessageReceived(BMessage* message)
|
|||||||
size--;
|
size--;
|
||||||
|
|
||||||
int32 keyCode;
|
int32 keyCode;
|
||||||
|
int32 buttons;
|
||||||
if (!message->IsSourceRemote()
|
if (!message->IsSourceRemote()
|
||||||
|
&& message->FindInt32("buttons", &buttons) == B_OK
|
||||||
|
&& (buttons & B_SECONDARY_MOUSE_BUTTON) != 0
|
||||||
&& message->FindInt32("key", &keyCode) == B_OK) {
|
&& message->FindInt32("key", &keyCode) == B_OK) {
|
||||||
// switch keys if the dropped object came from us
|
// switch keys if the dropped object came from us
|
||||||
Key* key = _KeyForCode(keyCode);
|
Key* key = _KeyForCode(keyCode);
|
||||||
if (key == NULL || key == fDropTarget)
|
if (key == NULL
|
||||||
|
|| (key == fDropTarget && fDragModifiers == fModifiers))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char* string;
|
char* string;
|
||||||
@@ -266,7 +267,7 @@ KeyboardLayoutView::MessageReceived(BMessage* message)
|
|||||||
if (string != NULL) {
|
if (string != NULL) {
|
||||||
fKeymap->SetKey(fDropTarget->code, fModifiers, fDeadKey,
|
fKeymap->SetKey(fDropTarget->code, fModifiers, fDeadKey,
|
||||||
(const char*)data, size);
|
(const char*)data, size);
|
||||||
fKeymap->SetKey(key->code, fModifiers, fDeadKey,
|
fKeymap->SetKey(key->code, fDragModifiers, fDeadKey,
|
||||||
string, numBytes);
|
string, numBytes);
|
||||||
delete[] string;
|
delete[] string;
|
||||||
}
|
}
|
||||||
@@ -281,6 +282,7 @@ KeyboardLayoutView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
_InvalidateKey(fDropTarget);
|
_InvalidateKey(fDropTarget);
|
||||||
fDropTarget = NULL;
|
fDropTarget = NULL;
|
||||||
|
fDropPoint.x = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
@@ -290,8 +292,10 @@ KeyboardLayoutView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_MODIFIERS_CHANGED:
|
case B_MODIFIERS_CHANGED:
|
||||||
if (message->FindInt32("modifiers", &fModifiers) == B_OK)
|
if (message->FindInt32("modifiers", &fModifiers) == B_OK) {
|
||||||
|
_EvaluateDropTarget(fDropPoint);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -692,6 +696,19 @@ KeyboardLayoutView::_SetFontSize(BView* view, key_kind keyKind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
KeyboardLayoutView::_EvaluateDropTarget(BPoint point)
|
||||||
|
{
|
||||||
|
fDropTarget = _KeyAt(point);
|
||||||
|
if (fDropTarget != NULL) {
|
||||||
|
if (fDropTarget == fDragKey && fModifiers == fDragModifiers)
|
||||||
|
fDropTarget = NULL;
|
||||||
|
else
|
||||||
|
_InvalidateKey(fDropTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardLayoutView::_SendFakeKeyDown(const Key* key)
|
KeyboardLayoutView::_SendFakeKeyDown(const Key* key)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ private:
|
|||||||
Key* _KeyAt(BPoint point);
|
Key* _KeyAt(BPoint point);
|
||||||
BRect _FrameFor(const Key* key);
|
BRect _FrameFor(const Key* key);
|
||||||
void _SetFontSize(BView* view, key_kind keyKind);
|
void _SetFontSize(BView* view, key_kind keyKind);
|
||||||
|
void _EvaluateDropTarget(BPoint point);
|
||||||
void _SendFakeKeyDown(const Key* key);
|
void _SendFakeKeyDown(const Key* key);
|
||||||
|
|
||||||
KeyboardLayout* fLayout;
|
KeyboardLayout* fLayout;
|
||||||
@@ -82,7 +83,9 @@ private:
|
|||||||
|
|
||||||
BPoint fClickPoint;
|
BPoint fClickPoint;
|
||||||
Key* fDragKey;
|
Key* fDragKey;
|
||||||
|
int32 fDragModifiers;
|
||||||
Key* fDropTarget;
|
Key* fDropTarget;
|
||||||
|
BPoint fDropPoint;
|
||||||
|
|
||||||
BFont fFont;
|
BFont fFont;
|
||||||
BFont fSpecialFont;
|
BFont fSpecialFont;
|
||||||
|
|||||||
Reference in New Issue
Block a user