Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data is different from menu?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Divers
Thread ID:
00048278
Message ID:
00048410
Vues:
24
>>>>I have a menu which repeats the command buttons on a form. One of them is Save. The command on the menu is _screen.activeform.cmdsave.click(). The click event runs code very similar to that found in the Wizbtns class of the screen wizard. When we hit Wizbtns.UpdateRows() basically a TableUpdate() is performed. If I choose Save from the menu, not only is the TableUpdate not performed correctly, but the changes are reverted. If I step through the code, the update IS performed correctly.
>>>>
>>>>I have done some Debugout() in the UpdateRows method and found something very odd...
>>>>
>>>>When the click() is fired by the menu, OLDVAL(Field, Table) and Table.Field will return exactly the same thing (the old value), even though the Table.Field value has been changed on the form. But they return different (correct) values when fired by clicking on the command button.
>>>>
>>>>I'm using optimistic table buffering, but, just for grins, I changed it to NO buffering and the same thing happens!!
>>>>
>>>>What's going on here? Any ideas? I'm stumped.
>>>>
>>>>Thanks.
>>>
>>>
>>>Calling the click method from a menu does not allow the button whose click method you are calling get the focus. Could that be what is causing the problem? Could you have some other code in place on the button that is run when it receives focus?
>>
>>
>>No. I didn't have any code in the GotFocus(). But, enlightened by your suggestion, I created a form method m_add and in that method did:
>>
>>Thisform.wizbtns.cmdadd.setfocus()
>>Thisform.wizbtns.cmdadd.click()
>>
>>And IT WORKED! BTW, without the setfocus() it does not work.
>>
>>Strange work around, but ya gotta do what ya gotta do!
>>
>>Thanks Brett.
>
>P.S. it also works with Thisform.wizbtns.setfocus(). In fact, it works if you setfocus back to ANY object on the form!

Valerie (and Bret) the reason for this is that if you click on a menu or toolbar button the focus in NOT removed from your activecontrol. As long as the focus is still there, the table.field value isn't updated to what's in the buffer.

When you de-bugged, you changed the focus - so it worked correctly. Your SetFocus() workaround simple moves the focus an extra time. Another way to do this is to have an invisible object as part of your base form class. Every toolbar button sets focus to that object before calling its own code/action.

HTH
Barbara
Barbara Paltiel, Paltiel Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform