Implemented focusing the Name property on pressing Command-E. (Ticket #2742)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33631 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-10-17 23:27:02 +00:00
parent df01744a4f
commit b24366c6d8
4 changed files with 39 additions and 10 deletions
+11 -7
View File
@@ -1,9 +1,6 @@
/* /*
* Copyright 2006-2008, Haiku. * Copyright 2006-2009, Stephan Aßmus <[email protected]>.
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/ */
#include "MainWindow.h" #include "MainWindow.h"
@@ -80,6 +77,8 @@ enum {
MSG_STYLE_RESET_TRANSFORMATION = 'rtst', MSG_STYLE_RESET_TRANSFORMATION = 'rtst',
MSG_MOUSE_FILTER_MODE = 'mfmd', MSG_MOUSE_FILTER_MODE = 'mfmd',
MSG_RENAME_OBJECT = 'rnam',
}; };
// constructor // constructor
@@ -358,6 +357,10 @@ case MSG_SHAPE_SELECTED: {
} }
break; break;
} }
case MSG_RENAME_OBJECT:
fPropertyListView->FocusNameProperty();
break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
} }
@@ -576,6 +579,7 @@ MainWindow::_Init()
AddShortcut('Y', 0, new BMessage(MSG_UNDO)); AddShortcut('Y', 0, new BMessage(MSG_UNDO));
AddShortcut('Y', B_SHIFT_KEY, new BMessage(MSG_REDO)); AddShortcut('Y', B_SHIFT_KEY, new BMessage(MSG_REDO));
AddShortcut('E', 0, new BMessage(MSG_RENAME_OBJECT));
} }
// _CreateGUI // _CreateGUI
@@ -1027,9 +1031,9 @@ MainWindow::_CreateMenuBar(BRect frame)
new BMessage(MSG_SAVE_AS), 'S', B_SHIFT_KEY)); new BMessage(MSG_SAVE_AS), 'S', B_SHIFT_KEY));
fileMenu->AddSeparatorItem(); fileMenu->AddSeparatorItem();
fileMenu->AddItem(new BMenuItem("Export", fileMenu->AddItem(new BMenuItem("Export",
new BMessage(MSG_EXPORT), 'E')); new BMessage(MSG_EXPORT), 'P'));
fileMenu->AddItem(new BMenuItem("Export As"B_UTF8_ELLIPSIS, fileMenu->AddItem(new BMenuItem("Export As"B_UTF8_ELLIPSIS,
new BMessage(MSG_EXPORT_AS), 'E', B_SHIFT_KEY)); new BMessage(MSG_EXPORT_AS), 'P', B_SHIFT_KEY));
fileMenu->AddSeparatorItem(); fileMenu->AddSeparatorItem();
fileMenu->AddItem(new BMenuItem("Quit", fileMenu->AddItem(new BMenuItem("Quit",
new BMessage(B_QUIT_REQUESTED), 'Q')); new BMessage(B_QUIT_REQUESTED), 'Q'));
@@ -80,13 +80,15 @@ class PropertyListView : public BView,
void Clicked(PropertyItemView* item); void Clicked(PropertyItemView* item);
void DoubleClicked(PropertyItemView* item); void DoubleClicked(PropertyItemView* item);
protected:
PropertyItemView* _ItemAt(int32 index) const;
int32 _CountItems() const;
private: private:
void _UpdateSavedProperties(); void _UpdateSavedProperties();
bool _AddItem(PropertyItemView* item); bool _AddItem(PropertyItemView* item);
PropertyItemView* _RemoveItem(int32 index); PropertyItemView* _RemoveItem(int32 index);
PropertyItemView* _ItemAt(int32 index) const;
int32 _CountItems() const;
void _MakeEmpty(); void _MakeEmpty();
@@ -13,8 +13,10 @@
#include <string.h> #include <string.h>
#include "CommandStack.h" #include "CommandStack.h"
#include "CommonPropertyIDs.h"
#include "IconObject.h" #include "IconObject.h"
#include "Property.h" #include "Property.h"
#include "PropertyItemView.h"
#include "PropertyObject.h" #include "PropertyObject.h"
#include "Selection.h" #include "Selection.h"
#include "SetPropertiesCommand.h" #include "SetPropertiesCommand.h"
@@ -161,6 +163,25 @@ IconObjectListView::SetCommandStack(CommandStack* stack)
fCommandStack = stack; fCommandStack = stack;
} }
// FocusNameProperty
void
IconObjectListView::FocusNameProperty()
{
if (fObject == NULL)
return;
int32 count = _CountItems();
for (int32 i = 0; i < count; i++) {
PropertyItemView* item = _ItemAt(i);
Property* property = item->GetProperty();
if (property != NULL && property->Identifier() == PROPERTY_NAME) {
item->MakeFocus(true);
break;
}
}
}
// #pragma mark - // #pragma mark -
// _SetObject // _SetObject
@@ -38,6 +38,8 @@ class IconObjectListView : public PropertyListView,
void SetSelection(Selection* selection); void SetSelection(Selection* selection);
void SetCommandStack(CommandStack* stack); void SetCommandStack(CommandStack* stack);
void FocusNameProperty();
private: private:
void _SetObject(IconObject* object); void _SetObject(IconObject* object);