Selection changes via keyboard no longer copy DiskProbe's original behaviour,
but can be done like in BTextView. Fixed a strange drawing bug that could happen on startup (R5): IsFocus() could return false, even if the view had focus. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7646 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -55,12 +55,13 @@ DataView::DataView(BRect rect, DataEditor &editor)
|
|||||||
fFocus(kHexFocus),
|
fFocus(kHexFocus),
|
||||||
fBase(kHexBase),
|
fBase(kHexBase),
|
||||||
fIsActive(true),
|
fIsActive(true),
|
||||||
|
fMouseSelectionStart(-1),
|
||||||
|
fKeySelectionStart(-1),
|
||||||
fBitPosition(0),
|
fBitPosition(0),
|
||||||
fFitFontSize(false)
|
fFitFontSize(false)
|
||||||
{
|
{
|
||||||
fPositionLength = 4;
|
fPositionLength = 4;
|
||||||
fStart = fEnd = 0;
|
fStart = fEnd = 0;
|
||||||
fMouseSelectionStart = -1;
|
|
||||||
|
|
||||||
if (fEditor.Lock()) {
|
if (fEditor.Lock()) {
|
||||||
fDataSize = fEditor.ViewSize();
|
fDataSize = fEditor.ViewSize();
|
||||||
@@ -93,6 +94,9 @@ void
|
|||||||
DataView::AttachedToWindow()
|
DataView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
fEditor.StartWatching(this);
|
fEditor.StartWatching(this);
|
||||||
|
MakeFocus(true);
|
||||||
|
// this seems to be necessary - if we don't do this here,
|
||||||
|
// the view is sometimes focus, but IsFocus() returns false...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -915,7 +919,7 @@ DataView::MouseMoved(BPoint where, uint32 transit, const BMessage */*dragMessage
|
|||||||
void
|
void
|
||||||
DataView::MouseUp(BPoint where)
|
DataView::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
fMouseSelectionStart = -1;
|
fMouseSelectionStart = fKeySelectionStart = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -927,41 +931,101 @@ DataView::KeyDown(const char *bytes, int32 numBytes)
|
|||||||
|| Looper()->CurrentMessage()->FindInt32("modifiers", &modifiers) != B_OK)
|
|| Looper()->CurrentMessage()->FindInt32("modifiers", &modifiers) != B_OK)
|
||||||
modifiers = ::modifiers();
|
modifiers = ::modifiers();
|
||||||
|
|
||||||
|
// check if the selection is going to be changed
|
||||||
switch (bytes[0]) {
|
switch (bytes[0]) {
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
SetSelection(fStart - 1, modifiers & B_SHIFT_KEY ? fEnd : fStart - 1);
|
|
||||||
MakeVisible(fStart);
|
|
||||||
break;
|
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
SetSelection(modifiers & B_SHIFT_KEY ? fStart : fEnd + 1, fEnd + 1);
|
case B_UP_ARROW:
|
||||||
MakeVisible(fEnd);
|
case B_DOWN_ARROW:
|
||||||
|
if (modifiers & B_SHIFT_KEY) {
|
||||||
|
if (fKeySelectionStart == -1)
|
||||||
|
fKeySelectionStart = fStart;
|
||||||
|
} else
|
||||||
|
fKeySelectionStart = -1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (bytes[0]) {
|
||||||
|
case B_LEFT_ARROW:
|
||||||
|
{
|
||||||
|
int32 position = fStart - 1;
|
||||||
|
|
||||||
|
if (modifiers & B_SHIFT_KEY) {
|
||||||
|
if (fKeySelectionStart == fEnd)
|
||||||
|
SetSelection(fStart - 1, fEnd);
|
||||||
|
else {
|
||||||
|
SetSelection(fStart, fEnd - 1);
|
||||||
|
position = fEnd;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
SetSelection(fStart - 1, fStart - 1);
|
||||||
|
|
||||||
|
MakeVisible(position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_RIGHT_ARROW:
|
||||||
|
{
|
||||||
|
int32 position = fEnd + 1;
|
||||||
|
|
||||||
|
if (modifiers & B_SHIFT_KEY) {
|
||||||
|
if (fKeySelectionStart == fStart)
|
||||||
|
SetSelection(fStart, fEnd + 1);
|
||||||
|
else
|
||||||
|
SetSelection(fStart + 1, fEnd);
|
||||||
|
} else
|
||||||
|
SetSelection(fEnd + 1, fEnd + 1);
|
||||||
|
|
||||||
|
MakeVisible(position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
{
|
{
|
||||||
int32 start = fStart - int32(kBlockSize);
|
int32 start, end;
|
||||||
if (start < 0) {
|
if (modifiers & B_SHIFT_KEY) {
|
||||||
if (modifiers & B_SHIFT_KEY)
|
if (fKeySelectionStart == fStart) {
|
||||||
|
start = fEnd - int32(kBlockSize);
|
||||||
|
end = fStart;
|
||||||
|
} else {
|
||||||
|
start = fStart - int32(kBlockSize);
|
||||||
|
end = fEnd;
|
||||||
|
}
|
||||||
|
if (start < 0)
|
||||||
start = 0;
|
start = 0;
|
||||||
else
|
} else {
|
||||||
|
start = fStart - int32(kBlockSize);
|
||||||
|
if (start < 0)
|
||||||
start = fStart;
|
start = fStart;
|
||||||
|
|
||||||
|
end = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelection(start, modifiers & B_SHIFT_KEY ? fEnd : start);
|
SetSelection(start, end);
|
||||||
MakeVisible(fStart);
|
MakeVisible(start);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_DOWN_ARROW:
|
case B_DOWN_ARROW:
|
||||||
{
|
{
|
||||||
int32 end = fEnd + int32(kBlockSize);
|
int32 start, end;
|
||||||
if (end >= int32(fSizeInView)) {
|
if (modifiers & B_SHIFT_KEY) {
|
||||||
if (modifiers & B_SHIFT_KEY)
|
if (fKeySelectionStart == fEnd) {
|
||||||
|
start = fEnd;
|
||||||
|
end = fStart + int32(kBlockSize);
|
||||||
|
} else {
|
||||||
|
start = fStart;
|
||||||
|
end = fEnd + int32(kBlockSize);
|
||||||
|
}
|
||||||
|
if (end >= int32(fSizeInView))
|
||||||
end = int32(fSizeInView) - 1;
|
end = int32(fSizeInView) - 1;
|
||||||
else
|
} else {
|
||||||
end = fEnd;
|
end = fEnd + int32(kBlockSize);
|
||||||
|
if (end >= int32(fSizeInView))
|
||||||
|
start = fEnd;
|
||||||
|
|
||||||
|
start = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelection(modifiers & B_SHIFT_KEY ? fStart : end, end);
|
SetSelection(start, end);
|
||||||
MakeVisible(fEnd);
|
MakeVisible(end);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ class DataView : public BView {
|
|||||||
bool fIsActive;
|
bool fIsActive;
|
||||||
int32 fStart, fEnd;
|
int32 fStart, fEnd;
|
||||||
int32 fMouseSelectionStart;
|
int32 fMouseSelectionStart;
|
||||||
|
int32 fKeySelectionStart;
|
||||||
int32 fBitPosition;
|
int32 fBitPosition;
|
||||||
bool fFitFontSize;
|
bool fFitFontSize;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user