Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When is the interactivechange event not operational in a grid?

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
0
16
AU
I have a 'coded' grid on a form in my app based on a table I have created in my program.
One cell contains a filename say 'myexhibit.jpg', with a command coded in to operate on a mouse click.
I wish to 'click' on this filename and open another form containing an image editing control.
After editing using this control there is an option to save the 'modified' image to a new filename.
This is all working correctly.
I want that new filename to replace the original contents in the cell.
When opened by a 'click' event the editing form is opened correctly but returning the new filename when closing does not replace the original contents.
So I tried
*!* PROCEDURE Click
PROCEDURE interactivechange
however this does not 'fire' when clicking on the cell.
So my question is - how can I return the new filename to the cell on the grid to replace the original entry?
Thanks

GenDev
 
how can I return the new filename to the cell on the grid to replace the original entry?

The same way that you would update or insert any information in a grid: namely, to update the underlying table or cursor. A grid is merely a window into a table or cursor (the one specified in the grid's RecordSource property). So update the relevant field in that cursor, using UPDATE or REPLACE. Then - and this is important - call the grid's SetFocus method to make the change visible.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

Yes I had tried that but I was getting errors trying to access that cursor - I'll try again.
Hmm - that worked - many thanks
GEnDev
 
I recognize you've solved it.

Nevertheless: I think you should learn that the InteractiveChange would happen when the user changes the value of a cell interactively, i.e. clicks into the cell and types keys, starts writing/modifing, and so I wonder why you changed from Click to InteractiveChange at all, it happens even later and only when a user would modify or enter a filename, which you want to be done by a GETFILE() call, I guess, so already the click into the control should handle that.

Did the click also not happen? Then the column may have been configured as disabled or the whole grid had allowcellselection set .F. or the underlying cursor is readonly.
Or users tabbed ito the field. Then click does not happen. What happens in both cases of activating the cell with the mouse or tabbing into it is GotFocus and even earlier the When event. So they could be used to trigger the choice of a filename.

The When event would be the ultimate check, whether a column control can be focussed (can become active) at all.

So, more generally the lessen here is, you have to understand when an event happens and pick the appropriate event for what you want to do when the event happened. If "InteractiveChange" sounds good to you because you want to write code into it that causes an interaction to change the filename. The name of this event indicates that it happens when that already happened, a user added a character or removed one, the value was changed. That does not happen by just activating a cell, that just puts in a text cursor, but the cursor is just an indicator to the user where the next change he does with keys will happen, no change happened yet. All events already have defined the reasons of things happening that cause them to run, you can't define what triggers an event nor can you actually create new events in VFP, you're limited to the events that already exist and to pick the right one means reading about what causes the events. What you program into them is not chanigng the events, it's programming what happens after the event that triggers the event method.

For example, the interactivechange event happens after the value was changed, not every key changes it, arrow keys just move the text cursor and don't change the value. The Keypress event happens after a key is pressed, but before it makes its change, if at all, to the control value. So KeyPRess and InteractiveChange in conjunction could be used for very intricate actions you want to happen or even prevent from happening, i.e. you could disallow some changes and allow others. You could even do such things as recoring the value in keypress and then in the follow up event InteractiveChange have the value before and after the change. In a field for a filename, I actually think you would want to prevent any change from the filename that is the result of a GETFILE() dialog to a changed filename, which has the risk of not existing, so you'd want such a cell to not be editable, just clickable, which could be done by setting readonly .T., that still allows to click or focus the cell, but not change it interactively, just by code you program, for example in When to pick a file name.

Chriss
 
Chriss
I changed it back to a click event and also recognized that I had misidentified the underlying table/cursor.
Anyway that problem is solved now - on with the next one.

Gendev

 
I have recognized the problem is solved.

Your usage of interactivechange instead of click suggests you think it would occur, too. And that shows fundamental misunderstandings about events and how they work. And if that's obvious it can help to reduce the source of problem arising in the future, if I address what I know is a total misundertanding about how things work.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top