KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Changing the behavior of menu items in a 4D Write area
PRODUCT: 4D Write | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: April 12, 2013

The behavior of a menu item in a 4D Write area can be changed by using the 4D Write command WR ON COMMAND. For example, the developer may want the "Save" and "Save as..." menu items to save a the current record or save a new record in the database rather than save the document externally. The command WR ON COMMAND will execute the replacement method everytime a 4D Write command is invoked by selecting a menu item or button within the 4D Write area.

Here is an example of how a replacement method can be used:

//Form method
If(Form event=On Load)
  WR ON COMMAND(4DWriteArea;"myMethod")
End if


The project method myMethod will be called everytime a 4D Write menu item is selected or a 4D Write button is click.

C_LONGINT($1;$2)
Case of
   : ($2=wr cmd save) //When "Save" command is invoked
     //...
   : ($2=wr cmd save as) //When "Save As..." command is invoked
     //...
   Else //When any other 4D Write command is invoked
     WR EXECUTE COMMAND ($1;$2) //Execute the regular action
End case