Loose ends for editing: drew the proper background for text and committing text works now.

This commit is contained in:
Pietro Gagliardi 2018-06-20 19:31:21 -04:00
parent ccb7005dc6
commit 5854b0f638
2 changed files with 25 additions and 2 deletions

View File

@ -233,6 +233,9 @@ static HRESULT drawTextPart(struct drawState *s)
if (!s->m->hasText)
return S_OK;
// don't draw the text underneath an edit control
if (s->t->edit != NULL && s->t->editedItem == s->iItem && s->t->editedSubitem == s->iSubItem)
return S_OK;
prevText = SetTextColor(s->dc, s->textColor);
if (prevText == CLR_INVALID) {

View File

@ -153,20 +153,40 @@ HRESULT uiprivTableResizeWhileEditing(uiTable *t)
HRESULT uiprivTableFinishEditingText(uiTable *t)
{
uiprivTableColumnParams *p;
uiTableData *data;
char *text;
if (t->edit == NULL)
return S_OK;
text = uiWindowsWindowText(t->edit);
data = uiNewTableDataString(text);
uiFreeText(text);
p = (*(t->columns))[t->editedSubitem];
(*(t->model->mh->SetCellValue))(t->model->mh, t->model, t->editedItem, p->textModelColumn, data);
uiFreeTableData(data);
// always refresh the value in case the model rejected it
if (SendMessageW(t->hwnd, LVM_UPDATE, (WPARAM) (t->editedItem), 0) == (LRESULT) (-1)) {
logLastError(L"LVM_UPDATE");
return E_FAIL;
}
return uiprivTableAbortEditingText(t);
}
HRESULT uiprivTableAbortEditingText(uiTable *t)
{
HWND edit;
if (t->edit == NULL)
return S_OK;
if (DestroyWindow(t->edit) == 0) {
// set t->edit to NULL now so we don't trigger commits on focus killed
edit = t->edit;
t->edit = NULL;
if (DestroyWindow(edit) == 0) {
logLastError(L"DestroyWindow()");
return E_FAIL;
}
t->edit = NULL;
return S_OK;
}