Le 03/09/2010 23:07, Dave Page a écrit :
> On Fri, Sep 3, 2010 at 9:24 PM, Steffen Kuhn <[email protected]> wrote:
>> Hi Guillaume,
>>
>> the delete problem is following:
>> deleting rows has got the shortcut 'del'. Disabeling row deletion disables
>> 'del'.
>> Even the key event WXK_DELETE is not fired.
>> So the solution of this problem which should been there since 'del' is the
>> shortcut for row delete
>> is to change the shortcut to eg. 'ctrl-del', to get the default behavior of
>> the del key.
>> Could you please comment this.
>
> Del on its own is the correct key. It should be able to do the "right
> thing" based on whether or not a cell is in edit mode.
>
Yeah, I agree. See patch attached (not yet commited).
--
Guillaume
http://www.postgresql.fr
http://dalibo.com
diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp
index 4e766e6..dca028c 100644
--- a/pgadmin/frm/frmEditGrid.cpp
+++ b/pgadmin/frm/frmEditGrid.cpp
@@ -128,7 +128,7 @@ frmEditGrid::frmEditGrid(frmMain *form, const wxString& _title, pgConn *_conn, p
toolBar->AddSeparator();
toolBar->AddTool(MNU_PASTE, _("Paste"), wxBitmap(clip_paste_xpm), _("Paste data from the clipboard."), wxITEM_NORMAL);
toolBar->AddSeparator();
- toolBar->AddTool(MNU_DELETE, _("Delete"), wxBitmap(delete_xpm), _("Delete selected rows."), wxITEM_NORMAL);
+ toolBar->AddTool(MNU_DELETE, _("Delete"), wxBitmap(delete_xpm), _("Delete selected row/text"), wxITEM_NORMAL);
toolBar->AddSeparator();
toolBar->AddTool(MNU_OPTIONS, _("Options"), wxBitmap(sortfilter_xpm), _("Sort/filter options."), wxITEM_NORMAL);
@@ -138,7 +138,6 @@ frmEditGrid::frmEditGrid(frmMain *form, const wxString& _title, pgConn *_conn, p
toolBar->Realize();
toolBar->EnableTool(MNU_SAVE, false);
toolBar->EnableTool(MNU_UNDO, false);
- toolBar->EnableTool(MNU_DELETE, false);
// Setup the limit bar
#ifndef __WXMAC__
@@ -170,9 +169,8 @@ frmEditGrid::frmEditGrid(frmMain *form, const wxString& _title, pgConn *_conn, p
editMenu->AppendSeparator();
editMenu->Append(MNU_COPY, _("&Copy\tCtrl-C"),_("Copy selected cells to clipboard."));
editMenu->Append(MNU_PASTE, _("&Paste\tCtrl-V"),_("Paste data from the clipboard."));
- editMenu->Append(MNU_DELETE, _("&Delete\tDel"),_("Delete selected rows."));
+ editMenu->Append(MNU_DELETE, _("&Delete\tDel"),_("Delete selected rows/text."));
editMenu->Enable(MNU_UNDO, false);
- editMenu->Enable(MNU_DELETE, false);
// View menu
@@ -396,7 +394,7 @@ void frmEditGrid::OnLabelRightClick(wxGridEvent& event)
wxArrayInt rows=sqlGrid->GetSelectedRows();
xmenu->Append(MNU_COPY, _("&Copy"),_("Copy selected cells to clipboard."));
xmenu->Append(MNU_PASTE, _("&Paste"),_("Paste data from the clipboard."));
- xmenu->Append(MNU_DELETE, _("&Delete"),_("Delete selected rows."));
+ xmenu->Append(MNU_DELETE, _("&Delete"),_("Delete selected rows/text."));
if ((rows.GetCount()) && (!sqlGrid->IsCurrentCellReadOnly()))
{
@@ -1070,33 +1068,27 @@ void frmEditGrid::OnDelete(wxCommandEvent& event)
wxStyledTextCtrl *text = (wxStyledTextCtrl *)sqlGrid->GetCellEditor(sqlGrid->GetGridCursorRow(), sqlGrid->GetGridCursorCol())->GetControl();
if (text && text->GetCurrentPos() <= text->GetTextLength())
{
- int len = text->GetSelectedText().Length();
- if (len)
- text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + len);
- else
- text->SetSelection(text->GetCurrentPos(), text->GetCurrentPos() + 1);
- text->Clear();
+ if (text->GetSelectionStart() == text->GetSelectionEnd())
+ text->SetSelection(text->GetSelectionStart(), text->GetSelectionStart()+1);
+ text->Clear();
}
}
else
{
wxTextCtrl *text = (wxTextCtrl *)sqlGrid->GetCellEditor(sqlGrid->GetGridCursorRow(), sqlGrid->GetGridCursorCol())->GetControl();
- if (text && text->GetInsertionPoint() <= text->GetLastPosition())
+ if (text)
{
- int len = text->GetStringSelection().Length();
- if (len)
- text->Remove(text->GetInsertionPoint(), text->GetInsertionPoint() + len);
+ long x, y;
+ text->GetSelection(&x, &y);
+ if (x != y)
+ text->Remove(x, x+y+1);
else
- text->Remove(text->GetInsertionPoint(), text->GetInsertionPoint() + 1);
+ text->Remove(x, x+1);
}
}
return;
}
- // If the delete button is disabled, don't try to delete anything
- if (!toolBar->GetToolEnabled(MNU_DELETE))
- return;
-
wxArrayInt delrows=sqlGrid->GetSelectedRows();
int i=delrows.GetCount();
@@ -1206,8 +1198,6 @@ void frmEditGrid::OnGridSelectCells(wxGridRangeSelectEvent& event)
}
}
}
- toolBar->EnableTool(MNU_DELETE, enable);
- editMenu->Enable(MNU_DELETE, enable);
}
event.Skip();
}
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers