summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-07 22:53:50 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-06-07 22:53:50 +0300
commit73afbd1a7788ba033e071fbf00b0758e6c883745 (patch)
treeee152c9d97bc635f2b66523d085e54ad81327d42
parentc5979e11b6b18e893cc96b31498eb7a3a30e3780 (diff)
SL-19815 Properly implement up and down keys
-rw-r--r--indra/newview/llinventorygallery.cpp84
-rw-r--r--indra/newview/llinventorygallery.h3
2 files changed, 85 insertions, 2 deletions
diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp
index a6cadea712..1610ef7f34 100644
--- a/indra/newview/llinventorygallery.cpp
+++ b/indra/newview/llinventorygallery.cpp
@@ -970,11 +970,11 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask)
{
// Might be better to get item from panel
S32 n = mItemIndexMap[item];
- if (n == 0)
+ n--;
+ if (n < 0)
{
n = mItemsAddedCount - 1;
}
- n--;
item = mIndexToItemMap[n];
LLUUID item_id = item->getUUID();
changeItemSelection(item_id, true);
@@ -1008,6 +1008,16 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask)
handled = TRUE;
break;
+ case KEY_UP:
+ scrollUp();
+ handled = TRUE;
+ break;
+
+ case KEY_DOWN:
+ scrollDown();
+ handled = TRUE;
+ break;
+
default:
break;
}
@@ -1020,6 +1030,50 @@ BOOL LLInventoryGallery::handleKeyHere(KEY key, MASK mask)
return handled;
}
+void LLInventoryGallery::scrollUp()
+{
+ mFilterSubString.clear();
+
+ if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1)
+ {
+ LLInventoryGalleryItem* item = getSelectedItem();
+ if (item)
+ {
+ S32 n = mItemIndexMap[item];
+ n -= mItemsInRow;
+ if (n >= 0)
+ {
+ item = mIndexToItemMap[n];
+ LLUUID item_id = item->getUUID();
+ changeItemSelection(item_id, true);
+ item->setFocus(TRUE);
+ }
+ }
+ }
+}
+
+void LLInventoryGallery::scrollDown()
+{
+ mFilterSubString.clear();
+
+ if (mInventoryGalleryMenu && mSelectedItemID.notNull() && mItemsAddedCount > 1)
+ {
+ LLInventoryGalleryItem* item = getSelectedItem();
+ if (item)
+ {
+ S32 n = mItemIndexMap[item];
+ n += mItemsInRow;
+ if (n < mItemsAddedCount)
+ {
+ item = mIndexToItemMap[n];
+ LLUUID item_id = item->getUUID();
+ changeItemSelection(item_id, true);
+ item->setFocus(TRUE);
+ }
+ }
+ }
+}
+
void LLInventoryGallery::showContextMenu(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& item_id)
{
if (mInventoryGalleryMenu && item_id.notNull())
@@ -1690,6 +1744,32 @@ BOOL LLInventoryGalleryItem::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL dro
return baseHandleDragAndDrop(mUUID, drop, cargo_type, cargo_data, accept, tooltip_msg);
}
+BOOL LLInventoryGalleryItem::handleKeyHere(KEY key, MASK mask)
+{
+ if (!mGallery)
+ {
+ return FALSE;
+ }
+
+ BOOL handled = FALSE;
+ switch (key)
+ {
+ case KEY_UP:
+ mGallery->scrollUp();
+ handled = true;
+ break;
+
+ case KEY_DOWN:
+ mGallery->scrollDown();
+ handled = true;
+ break;
+
+ default:
+ break;
+ }
+ return handled;
+}
+
void LLInventoryGalleryItem::setWorn(bool value)
{
mWorn = value;
diff --git a/indra/newview/llinventorygallery.h b/indra/newview/llinventorygallery.h
index 7d4431dbfb..7ff471b67b 100644
--- a/indra/newview/llinventorygallery.h
+++ b/indra/newview/llinventorygallery.h
@@ -80,6 +80,8 @@ public:
void* cargo_data, EAcceptance* accept, std::string& tooltip_msg) override;
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override;
BOOL handleKeyHere(KEY key, MASK mask) override;
+ void scrollUp();
+ void scrollDown();
void setFilterSubString(const std::string& string);
std::string getFilterSubString() { return mFilterSubString; }
@@ -250,6 +252,7 @@ public:
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
+ BOOL handleKeyHere(KEY key, MASK mask);
LLFontGL* getTextFont();