Paul,
I am still baffled with this one. It appears that if a cell is selected for editing and the text is changed, then if the user moves to another cell using the mouse, the callback reason sequence is 'END_EDIT' followed by a 'BEGIN_EDIT' for the newly selected cell. If the user exits using the return or a cursor key, then the callback sequence is 'BEGIN_EDIT', 'END_EDIT', 'BEGIN_EDIT'.
In my code I use 'BEGIN_EDIT' to determine the cell being edited and so because an extra one is initiated with keys movement mode, the edited contents of the previous cell are deposited in the the newly selected cell.
I would appreciate a bit of help.
Regards
Ian
winapp
include <windows.ins>
character*100 text,singular_text,temporary_text
common/callback_status/in_callback
common/lv_data/text(5),singular_text(10,4),temporary_text
COMMON/LV_INFO/IROW,ICOL,irow_last,icol_last,ichanged
character*20 callback_history
common/cb_hist/callback_history(1000)
common/cb_hist_number/nhist,irows(1000),icols(1000)
integer*4 sel(4),view
external lv_callback
callback_history=' '
nhist = 0
in_callback = 0
irow_last = 0
icol_last = 0
irow = 0
icol = 0
sel=0
view=1
text=' '
do i=1,4
singular_text(1,i)='one'
singular_text(2,i)='two'
singular_text(3,i)='three'
enddo
do i=1,4
do j=1,3
text(i+1)=trim(text(i+1))//'|'//trim(singular_text(j,i))
enddo
enddo
!text='||| '
text(1)='|a1_|a2_|a3_'
i=winio@('%ca[LV edit test]%ww&')
i=winio@('%^lv[show_selection_always,edit_cells,full_row_select,go_down_on_return]',500,200,text,5,sel,view,lv_callback)
print 100,(trim(text(i)),i=1,5)
do i=1,nhist
print*,i,callback_history(i),irows(i),icols(i)
enddo
100 format(a)
end
integer*4 function lv_callback()
include <windows.ins>
!character*100 edited_cell
common/callback_status/in_callback
COMMON/LV_INFO/IROW,ICOL,irow_last,icol_last,ichanged
character*100 text,singular_text,temporary_text
common/lv_data/text(5),singular_text(10,4),temporary_text
character*20 callback_history
common/cb_hist/callback_history(1000)
common/cb_hist_number/nhist,irows(1000),icols(1000)
lv_callback=2
!if(in_callback .eq. 0)then
! in_callback = 1
nhist = nhist + 1
callback_history(nhist) = clearwin_string@('callback_reason')
! print *,clearwin_string@('callback_reason')
if(clearwin_string@('callback_reason') .eq. 'BEGIN_EDIT')then
! irow_last = irow
! icol_last = icol
! print *,'clearwin_info@(''ROW_NUMBER'') ',clearwin_info@('ROW_NUMBER')
! print *,'clearwin_info@(''COLUMN_NUMBER'')',clearwin_info@('COLUMN_NUMBER')
irow=clearwin_info@('ROW_NUMBER')
ICOL=clearwin_info@('COLUMN_NUMBER')
endif
if(clearwin_string@('callback_reason') .eq. 'END_EDIT')then
! print *,'clearwin_string@(''EDITED_TEXT'')',clearwin_string@('EDITED_TEXT')
temporary_text = clearwin_string@('EDITED_TEXT')
irow_use = irow
icol_use = icol
if(icol_last .ne. icol)then
if(icol_last .ne. 0)icol_use = icol_last
endif
if(irow_last .ne. irow)then
if(irow_last .ne. 0)irow_use = irow_last
endif
if(temporary_text .ne. singular_text(icol_use,irow_use))then
ichanged = 1
singular_text(icol_use,irow_use)=clearwin_string@('EDITED_TEXT')
text(irow_use+1)=' '
do j=1,3
text(irow_use+1)=trim(text(irow_use+1))//'|'//trim(singular_text(j,irow_use))
enddo
call window_update@(text)
else
ichanged = 0
endif
irow_last = irow
icol_last = icol
! print *,'ichanged',ichanged
endif
! in_callback = 0
!endif
irows(nhist) = irow
icols(nhist) = icol
end