Zenity have provide any option to hide the button ? - zenity

I'm looking to create a dialog that required the user input to enable the OK button.
I'm going to write a shell script to trigger that action. May i know zenity have any option that can hide the button before the user type any input?
This is my script:
DISPLAY=:0.0 zenity --entry \
--title="Testing!" \
--text "Would you like to do something?\nPlease provide a valid reason:" \
--ok-label="OK" \
--cancel-label="Cancel" 2>/dev/null &

It's hard to make such things with shell dialogs ,
in zenity i don't think you can do anything to the buttons, but then there is yad a fork of zenity that has some other options like hiding buttons, but you still can't know when the user inputs anything before he presses enter,
So you can keep showing a dialog with no buttons till the user inputs anything to the dialog and then show the buttons but every time the user needs to either press "enter" or click "ok"
here's the way you can do it
x='';while [ -z $x ] ; do x=`yad --entry --no-buttons --title="Testing!" --text "Would you like to do something?\nPlease provide a valid reason:"`; done;yad --entry --title="Testing!" --text "Would you like to do something?\nPlease provide a valid reason:" --entry-text=$x

Related

Powershell (studio) - AutoComplete dropdown value clicks a button?

I'm building a GUI for a powershell script. It's a form built in Powershell studio.
I have this code which works well:
(Get-Content ".\historique.txt") | ? { $_.trim() -ne "" } | set-content ".\historique.txt"
$postes_historique = Get-Content ".\historique.txt"
$textboxPoste.AutoCompleteCustomSource.AddRange($postes_historique)
It takes what is in the "historique.txt" text file and suggests autocomplete values for the textbox like this:
On that texbox, i have a KEYDOWN event set up so when a user presses ENTER it clicks the button below the textbox:
$textboxPoste_KeyDown = [System.Windows.Forms.KeyEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.KeyEventArgs]
if ($_.KeyCode -eq 'Enter')
{
$buttonConnexion.PerformClick()
}
}
The strange part and my question is :
-If I click a value in the dropdown, it clicks the button. (UNWANTED BEHAVIOR)
-If I REMOVE that KeyDown enter event, it DOESN'T click the button. (Wanted behavior)
That seems very strange to me, it's as if when you click a dropdown value, the code understands it like "YOU PRESSED ENTER". What kind of weird correlation is that? I want to have both, which is being able to press down enter to click the button AND being able to choose an autocomplete value without it triggering a button click...Doesn't seem like too much to ask, no?
Thank you for your time.
Not sure if there is another solution but the work around in this case is :
REMOVE the keydown event that clicks the button when ENTER is pressed
and
REPLACE it by setting the form's AcceptButton to your button. This way when user presses ENTER, that button is triggered and the autocomplete dropdown acts as expected.

showForm, Command Action, and going-back

Going "back" from a form doesn't take me to the previous form but back to the main form. What am I doing wrong? Here's more detail:
I have a Command that takes you from the main form of my app to a "human setup" form. From that form if you click on a certain multibutton I go to another form (MaintenanceLevel) like this:
protected void onHumanSetup_MultiButtonMaintenanceAction(Component c, ActionEvent event) {
// Invoke the next level of form
showForm("MaintenanceLevel", null);
}
In the "MaintenanceLevel" form I have an Action set to Back, but when I click the menu bar to go back I end up back on the main-form and not the "human setup" where I want to be.
Edit:
Things have got a little worse!! Now when I go back in to view the Commands for my MaintenanceLevel form it's empty: it's forgetting the command I've entered :(
Here is my command setting for MaintenanceLevel form:
You don't need to define a back command. Remove it. Codename One automatically creates back commands for you.
The usage for this option is when you create a Button and place it within the form, then you want it to behave as a back button effectively (e.g. cancel button).

Prevent users from typing and clicking in MS Word Add-in

I am writting a MS Word Add-in, I create a button to run a long time work with text. My work requires that during the time it is excuted, no change can be made by user ( typing, clicking, deleting ...) When this work is completed, user can type and click as usual.
I have used
this.Application.Options.AllowClickAndTypeMouse = false;
However, this doesn't work.
Who can help me!
First, your approach is wrong. The Click and Type is Word functionality and has nothing to do with disabling user Mouse clicks
(For more information about Click and Type refer to here).
Now for your question, here is one approach I would suggest:
If the user is not able to do any action, I would expect an appropriate message, so my idea is to create a modal form by using:
myForm.ShowDialog();
It should do the job and block the active document until it get closed.
I would also add a nice progress bar and "Close" button which you will enable when work has done.

LostFocus method of a text box getting executed before Form_Unload

I am currently programming in MS Access VBA. I have a form with a textbox on it. I am executing some code on LostFocus event of the textbox.
However, when I close the form using mouse and by clicking on close button on right-top corner of the form, with cursor in the text box, I have noticed that LostFocus event is getting executed before Form_Unload event.
Is there a way to avoid this?
Also, where can I find priorities of the events?? Or How are priorities decided in VBA?
EDIT:
My exact application is like this.
I have a form in MS Access which is used for accepting users' login credentials.
I want to disble textbox for Password and Login button till a valid Username is entered. I check if the username is valid or not on onLostFocus event. Now, consider a case where this form is closed without entering anything in Username textbox. In that case, onLostFocus event gets executed before Form_Unload event.
However, for normal operation, I require onLostFocus event because, on that event I enable Password textbox and login button.
Could there be a different way of doing it??
The lost focus event is not usually the best event for code. Did you have a specific reason for using it? If so, you will need to add a condition to the execution.
The order of events for an Access form are:
Exit → LostFocus
If you are closing a form, the Exit and LostFocus events occur before
the events associated with closing the form (such as Unload,
Deactivate, and Close), as follows:
Exit (control) → LostFocus (control) → Unload (form) → Deactivate
(form) → Close (form)
-- http://office.microsoft.com/en-ie/access-help/order-of-events-for-database-objects-HP005186761.aspx
"I check if the username is valid or not on onLostFocus event."
Do your validation in the after update event of the username text box ... enable/disable the password text box as appropriate when the username value changes.
You can initially disable the the password text box at form load, assuming the form loads with the username text box empty.
using onDirty or onChange is probably better for what you're doing if it is a control that you're inserting data into. There's a bunch of better choices than onLostFocus. Without knowing anything specific makes it tough to know how to help you more specifically. I'd say just try another on Event, because due to the nature of onLostFocus, it'd be impossible to prepare for this contingency.

Unable to locate WindowID

I am currently testing a web app using selenium rc with eclipse. I've been having issues with a single pop up window which appears when a submit button is clicked. The confirmation window appears with a single 'ok' option.
I've also tried 'chooseOKonnextConfirmation' in conjunction with .getConfirmation but eclipse tells me no confirmation exists. I've tried inspecting the window itself with firebug but have been unable to get any results.
I also tried with "selenium.selectWindow(getAllWindowIDs ()[1]);" but selenium not recognizing "getAllWindowIDs".
Could somebody please tell me how I can retrieve the windowID and the associated API commands I need to implement to get rid of this problem?
from your description, i understand that you have an ALERT window being appeared after clicking SUBMIT button but not the CONFIRMATION window.
if my understanding is correct
( you said single OK button - ALERT window appears with single OK button - CONFIRMATION window appears with OK and CANCEL buttons - there is another window javascript can generate which is CONFIRMATION.it appears with TEXT field and OK and CANCEL buttons )
so you must use accordingly.
here is what you should use
if(selenium.isAlertPresent()) {
String message = selenium.getAlert();
}
this will consume you Alert window and you can check the message displayed on Alert window if you want.
if this is not please post write your comment
It's selenium.getAllWindowIds(); note the capitalisation. Don't forget to make sure the popup has already appeared (e.g. selenium.waitForPopUp()).
Yes sudarsan is correct if you have an alert.
If you have an popup window not an alert with OK button then you have to click OK when popup appears.
If you are unable to locate the button use firebug to locate the element.