Discussion:
Deactivate event for pagepanel
donJ
2017-12-29 21:03:29 UTC
Permalink
Hi,
Merry Christmas to all!

I have a pagepanel which includes a bunch of TextFields to allow the
user to edit information. Then, there are buttons: Cancel, Revert and Apply.

It works fine except, if the user forgets to apply the changes, there is
no warning. If he then selects a different record to edit, the info on
the pagepanel is changed, losing the first changes.

A pagepanel has an "AutoDeactivate" property, but no Activate or
Deactivate event to trigger a warning message.

I suppose I could set "enabled = false" for the other controls on the
window when the panel is accessed or the frist change is made, to avoid
changing the record, but there still would be no message.

Any ideas?

Thanks,
Don


To unsubscribe, email ***@xojo.com
Jim Wagner
2017-12-29 22:00:22 UTC
Permalink
I would have a boolean “Dirty”. It is set any time the user makes any change to any of the fields.

Then, in the close event or panel change event, check Dirty. If it is true, post a warning about saving the changes.

Simple. That is the way many applications do it.

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by donJ
Hi,
Merry Christmas to all!
I have a pagepanel which includes a bunch of TextFields to allow the user to edit information. Then, there are buttons: Cancel, Revert and Apply.
It works fine except, if the user forgets to apply the changes, there is no warning. If he then selects a different record to edit, the info on the pagepanel is changed, losing the first changes.
A pagepanel has an "AutoDeactivate" property, but no Activate or Deactivate event to trigger a warning message.
I suppose I could set "enabled = false" for the other controls on the window when the panel is accessed or the frist change is made, to avoid changing the record, but there still would be no message.
Any ideas?
Thanks,
Don
To unsubscribe, email ***@xojo.com
donJ
2017-12-29 22:21:46 UTC
Permalink
I would have a boolean “Dirty”. It is set any time the user makes any
change to any of the fields.
Then, in the close event or panel change event, check Dirty. If it is
true, post a warning about saving the changes.
Simple. That is the way many applications do it.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net
Hi James,

Yes, that is basically what I'm looking for, but it fires at the wrong time.

It's a simple window. A listbox with a long list of names and a page
panel tht displays different info about each name. I put code in the
pagepanel close event, but this is what happens:
I select a name from the listbox. I switch to the correct page panel and
make a change. Now, if I select a different name from the listox, it
changes to another person, losing the new info in the page panel, and
then the message box about not applying the new data appears.

I forgot to put in my first email:
Xojo 2016r4.1
Linux mint 18 - 32 bit system

Thanks for your time,
Don




To unsubscribe, email ***@xojo.com
Jim Wagner
2017-12-29 22:35:56 UTC
Permalink
Trap it where you change the page panel, before any of the new text fields are populated. There is some sample code that demonstrates the use of a MessageDialog that halts the execution of code and does not proceed until the user clicks one of the dialog buttons. Check MessageDialog in the LR for example code. It works nicely. It will prevent the new fields from being populated before the previous one is saved or discarded.

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by donJ
Post by Jim Wagner
I would have a boolean “Dirty”. It is set any time the user makes any change to any of the fields.
Then, in the close event or panel change event, check Dirty. If it is true, post a warning about saving the changes.
Simple. That is the way many applications do it.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net
Hi James,
Yes, that is basically what I'm looking for, but it fires at the wrong time.
I select a name from the listbox. I switch to the correct page panel and make a change. Now, if I select a different name from the listox, it changes to another person, losing the new info in the page panel, and then the message box about not applying the new data appears.
Xojo 2016r4.1
Linux mint 18 - 32 bit system
Thanks for your time,
Don
To unsubscribe, email ***@xojo.com
Jim Wagner
2017-12-29 22:37:30 UTC
Permalink
Also, do not forget to do the same thing if the window is closed (without changing page panels) when it is dirty.

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by donJ
Post by Jim Wagner
I would have a boolean “Dirty”. It is set any time the user makes any change to any of the fields.
Then, in the close event or panel change event, check Dirty. If it is true, post a warning about saving the changes.
Simple. That is the way many applications do it.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net
Hi James,
Yes, that is basically what I'm looking for, but it fires at the wrong time.
I select a name from the listbox. I switch to the correct page panel and make a change. Now, if I select a different name from the listox, it changes to another person, losing the new info in the page panel, and then the message box about not applying the new data appears.
Xojo 2016r4.1
Linux mint 18 - 32 bit system
Thanks for your time,
Don
To unsubscribe, email ***@xojo.com
donJ
2017-12-30 17:00:11 UTC
Permalink
Post by Jim Wagner
Also, do not forget to do the same thing if the window is closed
(without changing page panels) when it is dirty.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net
Hi Jim,
I trapped it in the Listbox mousedown event. This way it applys (or not)
the changes before the listbox change. And yes, I did catch it in
CancelClose.

Thank you,

Don


To unsubscribe, email ***@xojo.com
Antonio Rinaldi
2017-12-31 16:58:45 UTC
Permalink
The dirty property/event already exist in a Window: it's the contentsChanged property/event

When the user modify the data you can set the property to true, in the event (that has the same name) enable/disable the save/cancel/apply buttons using the property value, check the property value in the cancelClose event and before changing the record with the listbox, finally set the property to false every time you load/create a record.

Ciao
Antonio
Post by donJ
Post by Jim Wagner
Also, do not forget to do the same thing if the window is closed (without changing page panels) when it is dirty.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net
Hi Jim,
I trapped it in the Listbox mousedown event. This way it applys (or not) the changes before the listbox change. And yes, I did catch it in CancelClose.
Thank you,
Don
To unsubscribe, email ***@xojo.com
donJ
2017-12-31 18:29:12 UTC
Permalink
Post by Antonio Rinaldi
The dirty property/event already exist in a Window: it's the contentsChanged property/event
When the user modify the data you can set the property to true, in the event (that has the same name) enable/disable the save/cancel/apply buttons using the property value, check the property value in the cancelClose event and before changing the record with the listbox, finally set the property to false every time you load/create a record.
Ciao
Antonio
Thank you antonio. I never noticed a contentchanged event before. I'll
look at that this evening. If it fires when the content of an enclosed
control changes, that would be convenient.

Thank you
Don


To unsubscribe, email ***@xojo.com
Antonio Rinaldi
2018-01-01 10:06:34 UTC
Permalink
It doesn't fire when a control changes, but when the control changes you can test if you need the event and set the property contentsChanged to true (or false) and as consequence the event (contentsChanged will fire)

It's a little hard to explain in words, try it with a simple project.
It's hard since you have both an event and a property with the same name. But when you start to use it, you will understand quickly how it is really useful

Antonio
Post by Antonio Rinaldi
The dirty property/event already exist in a Window: it's the contentsChanged property/event
When the user modify the data you can set the property to true, in the event (that has the same name) enable/disable the save/cancel/apply buttons using the property value, check the property value in the cancelClose event and before changing the record with the listbox, finally set the property to false every time you load/create a record.
Ciao
Antonio
Thank you antonio. I never noticed a contentchanged event before. I'll look at that this evening. If it fires when the content of an enclosed control changes, that would be convenient.
Thank you
Don
To unsubscribe, email ***@xojo.com

Loading...