Silverfrost Forums

Welcome to our forums

%lv edit_cells

17 Dec 2006 12:19 #1454

When editing a list view cell, typing normal characters results in a callback with reason 'EDIT_KEY_DOWN'. If for example, the delete key is pressed, no callback occurs and so the program is unaware of this type of change to the text. Surely this is an omission?

There is also no response to function keys, and the action of the TAB key can be quite strange.

FTN95 Version 4.9.1.

18 Dec 2006 7:35 #1455

Ian

Thanks for this. I will add it to the list of things to investigate.

18 Dec 2006 12:26 #1457

Paul,

I used add_keyboard_monitor@, and am now able to detect the required key presses, however, I can't read the cell because

clearwin_string@('EDITED_TEXT'), clearwin_info@('COLUMN_NUMBER') clearwin_info@('ROW_NUMBER')

all produce no sensible result, due to the keyboard monitor having nothing to do with the list view. Is there some way to read an arbitary cell in the list view window?

Regards

Ian

21 Dec 2006 8:16 #1475

Ian

I think the data may be stored dynamically in the CHARACTER array in your code. If this is the case then you will be able to access the content of any cell directly.

Regarding the interactive processing of key strokes, the only temporary workaround that I can suggest is to try using %mg with WM_KEYDOWN.

21 Dec 2006 11:09 #1478

Paul,

I tried looking in the character arrays, and these have to be updated manually in response to the callback, so that didn't work.

What does the %mg do - I havn't a clue - is there and example.

Using the add_keyboard_monitor@ worked but I can't read the cell contents. I looked listviews up on microsoft, see link. http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.getitemat.aspx

but i have no idea how to call getitemat method in FTN95 or even whether this is the correct function to get the cell contents.

Help!

Ian

22 Dec 2006 7:57 #1483

Ian

At first sight it looks like the documentation for %lv in ftn95.chm is incomplete. Additional information can be found in the ClearWin enhancements file (probably cw.enh). You can return the value 4 from the callback to reject a character or an ascii value to translate to a different key. I guess other returned values will accept the key. You should be able to use the CHARACTER array to see what is in any cell.

%mg is documented in ftn95.chm. Examples are hard to come by.

13 Feb 2007 12:53 #1655

I am still persevering with the %lv display and using it for editing and have a few other problems. The system I am writing allows for some columns to be editable and others to be display only. The problems are:

  1. There is no callback response to the delete and backspace keys, so although it appears to have been edited, the result cannot be obtained.

  2. Un-fathomable operation of the tab key.

  3. When in a non-editable field, (callback result=4), in column 1, the field is highlighted and up-down cursor keys move from row to row, initiating an appropriate scroll at the control's boundaries. When in an editable field, the scroll does not happen.

  4. When in an non-editable field, there is noway out of the field using the keyboard. Must resort to the mouse.

  5. When a non-column 1, non-editable field is clicked, it is not highlighted, all sense of position is lost, i.e. different response to column 1.

  6. When moving from one editable field to another, with keyboard cursor keys, there is no way to initiate a partial edit of the cell without resorting to the mouse. A function like Excel or Explorer, whereby F2 initiates an edit would be useful.

  7. No way to determine the cursor character position within the field when the callback is initiated, or even to set this position.

Regards

Ian

15 Feb 2007 4:54 #1676

Although I would like to help you with this, realistically the task is too large to attempt without direct funding. If you would like to single out one priority item from your list, I will add it to the list of jobs to do.

15 Feb 2007 6:16 #1678

Paul,

I would say that the highest priority is for the callback response, but could I suggest that the callback is initiated for all keys, maybe with a different callback reason, ('CONTROL_KEY_DOWN' perhaps). This would maintain backward compatibility. A new function of clearwin_info@('CONTROL_KEY') would then be useful to determine the intent of the keypress and leave the rest up to the programmer.

I would also be pleased if you could put the rest of these items on the list and ponder them in your own time. As far as direct funding is concerned, I might stretch to £20.00 above and beyond the maintainance that I have been paying for about the last 11 years. Sadly the users of the programs I write, seem to pay even less than I can stretch to, and they are all labours of love.

At the time of writing, this forum topic has had 463 views, (no! not all by me!) and it could therefore be dear to the hearts of others.

Regards

Ian Lambley

15 Feb 2007 6:31 #1679

Forgive me if I am amused by the bit about 'ponder them in your own time'. However, my offer remains and if you want to supply sample code for your priority issue it would speed things up when I get to this item in the list of jobs.

5 Mar 2007 2:16 #1777

You are forgiven for you amusement status, and I am glad that my comments are able to raise a smile. I have tried to e-mail you with some sample code, but the e-mails just seem to remain in the outbox and I do not know whether you receive them.

6 Mar 2007 4:37 #1780

Paul, I also have messages to you in my outbox, but no idea of how they get to the sent box, which I presume is where they would go when they are sent ?? Any advice on how the message system works ?

John

6 Mar 2007 8:52 #1781

I do not routinely read my message box on this forum. Questions that are potentially of general interest should be posted in the main forum. When directed I will pick up files that have been posted in my message box but I may need to be reminded.

I now have Ian's zip file and I will take a look at it as soon as I can.

John, I have now read your message and will send a reply.

8 Mar 2007 12:27 #1791

A big thanks to 'BB' who e-mailed me some code. It appears that the 'EDITED_TEXT' function is best called when the edit is complete and the 'END_EDIT' callback reason is in force. I was originally trying to use this within 'EDIT_KEY_DOWN' to check the contents of the cell in response to each keystroke, something that I regularly do for the %rd, %rf & %rs formats. Instant updating of the calculation would then have been possible in the way that it is for those other controls. However, as the control callback does not respond to every keypress, then this did not work. I can now only use the data after exiting from the edited cell.

Other spurious events and responses still apply.

1 Oct 2008 12:22 #3863

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
2 Oct 2008 1:53 #3866

Looks like the code you posted is not complete.

3 Oct 2008 11:25 #3868

Here is the complete code for the callback, main program remains the same. Note, I used an array to store the list of callbacks as using a print within the callback produced the error regarding printing whilst already printing.

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
3 Oct 2008 8:20 #3870

I have taken your sample as a starting point and created a listbox control that a) rejects numerical input and b) converts lower case alpha characters to upper case. In the process it has become apparent that %lv is not fully documented even in the enhancements file. I am hoping that the new sample will help to show what can be done. I have not aimed to be clever when merging the strings. There will be a better way to do it.

winapp 
include <windows.ins> 
character*100 text 
common/lv_data/text(5)
integer*4 sel(4),view,lv_callback
external lv_callback 
sel=0 
view=1 
text='|one|two|three' 
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) 
end 

integer*4 function lv_callback()
include <windows.ins> 
integer input_char,ret_val,irow,icol
character*80 this_text  
character*100 text,tmp 
common/lv_data/text(5)
ret_val = 1
if(clearwin_string@('CALLBACK_REASON') == 'EDIT_KEY_DOWN')then
  input_char = clearwin_info@('KEYBOARD_KEY')
  if(input_char >= ichar('0') .AND. input_char <= ichar('9'))then
    ret_val = 4
  elseif(input_char >= ichar('a') .AND. input_char <= ichar('z'))then
    ret_val = input_char+ichar('A')-ichar('a')
  endif  
elseif(clearwin_string@('CALLBACK_REASON') == 'END_EDIT')then
  irow = clearwin_info@('ROW_NUMBER')
  irow = irow+1
  icol = clearwin_info@('COLUMN_NUMBER')
  this_text = clearwin_string@('EDITED_TEXT')
  index2 = index(text(irow)(2:),'|') + 1
  index3 = index(text(irow),'|', BACK=.TRUE.)
  if(icol == 1) then
    text(irow) = '|'//trim(this_text)//text(irow)(index2:)
  elseif(icol==2) then
    text(irow) = text(irow)(1:index2)//trim(this_text)//text(irow)(index3:)
  elseif(icol==3) then
    text(irow) = text(irow)(1:index3)//this_text
  endif
  call window_update@(text)
endif   
lv_callback = ret_val
end 
4 Oct 2008 5:53 #3871

I have had another go at this and I have simplified and improved the code

winapp 
character(len=100) text(5) 
common/lv_data/text
integer sel(4),lv_callback,winio@
external lv_callback 
sel=0 
text='|one|two|three' 
text(1)='|a1_100|a2_100|a3' 
i=winio@('%ww%ca[LV edit test]&') 
i=winio@('%^lv[edit_cells,go_down_on_return]',500,200,text,5,sel,1,lv_callback) 
end 

integer function lv_callback()
include <windows.ins> 
integer input_char,irow,icol,i1,i2
character(len=100) text(5),input,tmp
common/lv_data/text
lv_callback = 1
if(clearwin_string@('CALLBACK_REASON') == 'EDIT_KEY_DOWN')then
  input_char = clearwin_info@('KEYBOARD_KEY')
  if(input_char >= ichar('0') .AND. input_char <= ichar('9'))then
    lv_callback = 4                                !Filter out numeric values
  elseif(input_char >= ichar('a') .AND. input_char <= ichar('z'))then
    lv_callback = input_char+ichar('A')-ichar('a') !Convert lower case to upper
  endif  
elseif(clearwin_string@('CALLBACK_REASON') == 'END_EDIT')then
  irow = clearwin_info@('ROW_NUMBER') + 1
  icol = clearwin_info@('COLUMN_NUMBER')
  input = clearwin_string@('EDITED_TEXT')
  tmp = text(irow)
  i1 = 0
  do i=1,icol
    i1 = index(tmp(i1+1:),'|') + i1
  enddo
  i2 = index(tmp(i1+1:),'|') + i1
  if(i2>i1)then
    tmp = tmp(1:i1)//trim(input)//tmp(i2:)
  else
    tmp = tmp(1:i1)//trim(input)
  endif
  if(tmp /= text(irow)) then
    text(irow) = tmp
    call window_update@(text)
  endif  
endif   
end 
4 Oct 2008 6:23 #3872

Thanks Paul, take the rest of the evening off!

I notice that when one uses the cursor keys to move right or left, and the contents of the current cell are highlighted, it moves to the next or previous cells and they become highlighted. When in the last column, the right cursor unhighlights to contents and allows in-cell editing. To unhighlight the contents of any cell, for in-cell edits, the Home and End keys move to edit mode at the start or end of the cell. If the tab key is pressed, the highlighted region is lost and the mouse has to be used to select anything. Is this intentional?

Regards

Ian

Please login to reply.