Profile Picture

Loading without prompting to save

Posted By NeilTurp 7 Years Ago
Author
Message
NeilTurp
Problem Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
I have a app, xamarin on OSX, it has a list of topics,  When the user selects a topic, the app searches a folder and loads the relevant file if there is one, and shows an empty text editor window if there is not.  The user can edit the file and when they move to another topic, it automatically saves - there is no time when the user is asked to find a file to load or to give a file a name to save.  The code is:

Nevron.Nov.Text.Formats.NTextFormat tf = new Nevron.Nov.text.Formats.NRtfTextFormat();
if (System.IO.File.Exists(<FileName read from list>Wink)
{
     tvKey.LoadFromFile(<Filename>, tf, false);
}
else {
    tvKey.LoadNewDocument(); 
}

      
It all works ok if there is a file there to start with, the problem occurs if there is no data file to read and the user types into the text window.  In this case, the file is saved, all code exits, perfect, and then it shows a dialog that asks the user to Save, Don't Save, Cancel.  I can't see what I've missed.  Any ideas?
Neil

Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi,

The prompt to save message appears when there are unsaved changes to the document, i.e. when the document is in modified state. The modified flag is cleared when the document is saved, so the prompt to save message should not appear unless you are doing some modifications to the document after it has been saved. Please check your code and make sure you are not doing any changes to the document after it has been saved.

Best Regards,
Nevron Support Team



NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
Thanks, that is what I was expecting, but this all happens after the code has automatically saved the changes with SaveToFile. More detail, sorry I should have included this first: here is a fuller snippet of the code.

The user selects a new item from the list then this code is called:
if (dirty1)
{
 ts = new Nevron.Nov.Test.Formats.NTextSaveSettings();
 tvKey.SaveToFile(sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + OldRemedy.user.rtfd", tf, ts);
 dirty1 = false; 
}

if (ov.SelectedRow > -1)
{
 BookChap bc = (BookChap)ov.ItemAtRow(ov.SelectedRow);
 sRTF = sResPath + "My Keynotes/";
 Nevron.Nov.Text.Formats.NTextFormat tf = new Nevron.Nov.Text.Formats.NRtfTextFormat();

 if (System.IO.File.Exists(sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + <bc.Name>.user.rtfd"))
 {
   sRTF = sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + <bc.Name>.user.rtfd");
   tvKey.LoadFromFile(sRTF, tf, false);
 }
 else
 {
   sRTF = "";
   tvKey.LoadNewDocument();
 }
}

I am tracking changes to the control using the dirty1 bool flag. When the user selects a new item from the list, it saves the old file automatically if there are changes. I hope you can see that the code saves the file then tries to load the new file. If the user was looking at a pre-existing file loaded with LoadFromFile, all is ok. The problem occurs if he selects an item from the list that does not currently have a file associated - a new document is loaded using LoadNewDocument - and the user then types something into the blank document. Finally he selects another item from the list - the code above saves the changes into a new file, then loads the newly selected item, and then I see the "Save, Don't Save, Cancel" dialog. After the file has saved successfully. How can I suppress this? I guess the real question is, how do I change the "modified state" of the old document before I try and load the new one?

Thanks


Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi,

Thank you for the detailed description of your project. It appears that there was a bug in our component that resulted in showing the "Save changes" dialog in some cases in which it should not be shown. Fortunately, we have managed to fix the bug and the fix will be included in the upcoming major new version of Nevron Open Vision (v2017.1). The new version will be available for download later today and will also feature many other improvements in our components and the NOV framework.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic