Changeset 389 for cafu/trunk

Show
Ignore:
Timestamp:
09/20/11 22:56:52 (8 months ago)
Author:
Carsten
Message:

Gui Editor:
Revised handling of "rename window" events.

Location:
cafu/trunk/CaWE/GuiEditor
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaWE/GuiEditor/WindowTree.cpp

    r388 r389  
    6363    EVT_LEFT_DCLICK          (WindowTreeT::OnTreeLeftClick) // Handle double clicks like normal left clicks when it comes to clicks on tree item icons (otherwise double clicks are handled normally). 
    6464    EVT_TREE_SEL_CHANGED     (wxID_ANY, WindowTreeT::OnSelectionChanged) 
    65     EVT_TREE_END_LABEL_EDIT  (wxID_ANY, WindowTreeT::OnLabelChanged) 
     65    EVT_TREE_END_LABEL_EDIT  (wxID_ANY, WindowTreeT::OnEndLabelEdit) 
    6666    EVT_TREE_ITEM_RIGHT_CLICK(wxID_ANY, WindowTreeT::OnTreeItemRightClick) 
    6767    EVT_TREE_BEGIN_DRAG      (wxID_ANY, WindowTreeT::OnBeginDrag) 
     
    398398 
    399399 
    400 void WindowTreeT::OnLabelChanged(wxTreeEvent& TE) 
    401 { 
    402     // Emtpy string means the user has either not changed the label at all or 
    403     // deleted the whole label string. 
    404     if (TE.GetLabel()=="") 
    405     { 
    406         TE.Veto(); // Reset value. 
    407         return; 
    408     } 
    409  
     400void WindowTreeT::OnEndLabelEdit(wxTreeEvent& TE) 
     401{ 
    410402    cf::GuiSys::WindowT* Window=((WindowTreeItemT*)GetItemData(TE.GetItem()))->GetWindow(); 
    411403 
     404    if (TE.IsEditCancelled()) return; 
     405 
    412406    m_IsRecursiveSelfNotify=true; 
    413  
    414     if (!m_Parent->SubmitCommand(new CommandModifyWindowT(m_GuiDocument, Window, "Name", Window->GetMemberVar("name"), TE.GetLabel()))) 
    415     { 
    416         TE.Veto(); // Reset value if not valid. 
    417     } 
     407    m_Parent->SubmitCommand(new CommandModifyWindowT(m_GuiDocument, Window, "Name", Window->GetMemberVar("name"), TE.GetLabel())); 
     408    m_IsRecursiveSelfNotify=false; 
    418409 
    419410    // The command may well have set a name different from TE.GetLabel(). 
    420411    TE.Veto(); 
    421412    SetItemText(TE.GetItem(), Window->Name); 
    422  
    423     m_IsRecursiveSelfNotify=false; 
    424413} 
    425414 
  • cafu/trunk/CaWE/GuiEditor/WindowTree.hpp

    r374 r389  
    9191        void OnTreeLeftClick     (wxMouseEvent& ME); 
    9292        void OnSelectionChanged  (wxTreeEvent&  TE); 
    93         void OnLabelChanged      (wxTreeEvent&  TE); 
     93        void OnEndLabelEdit      (wxTreeEvent&  TE); 
    9494        void OnTreeItemRightClick(wxTreeEvent&  TE); 
    9595        void OnBeginDrag         (wxTreeEvent&  TE); 
  • cafu/trunk/CaWE/GuiEditor/Windows/EditorWindow.cpp

    r388 r389  
    241241        // Specially treated by command. 
    242242        ChildFrame->SubmitCommand(new CommandModifyWindowT(m_GuiDoc, m_Win, PropName, DummyVar, Prop->GetValueAsString())); 
     243 
     244        // The command may well have set a name different from Prop->GetValueAsString(). 
     245        wxASSERT(Event.GetEventType() == wxEVT_PG_CHANGED); 
     246        Event.GetProperty()->SetValueFromString(m_Win->Name); 
    243247    } 
    244248    else if (PropName=="Visible")