Is there a way to check for user rights at the time of press a button? I mean if a user press a button on a window, ask for user/password and only if the user has the proper rights execute the action?
To disable the button you can use the built in security, to do a one off authentication challenge, you'll have to script it.
For general checking of the current roles of the user, the tag [system]Client/User/RolesDataSet
contains the roles of the currently logged in user.
Your general flow would be to create a generic login popup for the auth challenge that has a
parameter for a callback function name. This callback function should exist on the window containing the button that will request the challenge.
On submitting a login, the popup window should only validate the login and get the roles of the user, and then pass this information when calling the defined callback function. This callback function should have the decision making logic to determine what to do (either perform x action or toss a warning at the user that they don't have the rights to perform the action)