Skip to content

Commit ad81509

Browse files
author
Joachim Meyer
committed
Fixes that if you clicked twice on an asset in the AssetBrowser, it would be viually deselected. You now can choose assets by doubleclicking them in the browser.
1 parent 1e42cde commit ad81509

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

IDE/Contents/Source/TextureBrowser.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void AssetList::showFolder(String folderPath) {
215215
if(hasExtension(entry.extension)) {
216216
AssetEntry *newEntry = new AssetEntry(entry.fullPath, entry.name, entry.extension, NULL);
217217
newEntry->selectShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
218+
newEntry->selectShape->addEventListener(this, InputEvent::EVENT_DOUBLECLICK);
218219
assetEntries.push_back(newEntry);
219220
newEntry->setPosition(xPos, yPos);
220221
xPos += 120;
@@ -244,14 +245,19 @@ void AssetList::handleEvent(Event *event) {
244245
showFolder(currentFolderPath);
245246
} else {
246247
for(int i=0; i < assetEntries.size(); i++) {
247-
if(event->getDispatcher() == assetEntries[i]->selectShape && event->getEventCode() == InputEvent::EVENT_MOUSEDOWN) {
248-
assetEntries[i]->selectShape->visible = true;
249-
selectedPath = assetEntries[i]->assetPath;
250-
if(currentEntry) {
251-
currentEntry->selectShape->visible = false;
248+
if (event->getDispatcher() == assetEntries[i]->selectShape) {
249+
if (event->getEventCode() == InputEvent::EVENT_MOUSEDOWN){
250+
if (currentEntry) {
251+
currentEntry->selectShape->visible = false;
252+
}
253+
assetEntries[i]->selectShape->visible = true;
254+
selectedPath = assetEntries[i]->assetPath;
255+
currentEntry = assetEntries[i];
256+
selectedResource = assetEntries[i]->resource;
257+
}
258+
if (event->getEventCode() == InputEvent::EVENT_DOUBLECLICK){
259+
dispatchEvent(new UIEvent(), UIEvent::OK_EVENT);
252260
}
253-
currentEntry = assetEntries[i];
254-
selectedResource = assetEntries[i]->resource;
255261
}
256262
}
257263
}
@@ -281,9 +287,10 @@ AssetBrowser::AssetBrowser() : UIWindow(L"Asset Browser", 850, 500) {
281287

282288

283289
assetList = new AssetList();
284-
290+
assetList->addEventListener(this, UIEvent::OK_EVENT);
291+
285292
listContainer = new UIScrollContainer(assetList, false, true, 640, 480-topPadding-padding-padding);
286-
listContainer->setPosition(220,topPadding+padding);
293+
listContainer->setPosition(220,topPadding+padding);
287294
addChild(listContainer);
288295

289296
cancelButton = new UIButton(L"Cancel", 100);
@@ -409,6 +416,9 @@ void AssetBrowser::handleEvent(Event *event) {
409416
removeAllHandlers();
410417
}
411418
}
419+
if (event->getEventCode() == UIEvent::OK_EVENT){
420+
dispatchEvent(new UIEvent(), UIEvent::OK_EVENT);
421+
}
412422
}
413423

414424
if(event->getEventType() == "UITreeEvent" && event->getEventCode() == UITreeEvent::SELECTED_EVENT) {

0 commit comments

Comments
 (0)