cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
JMPPRO
Level II

How to grey out OK button if user input is missing

Hello,

 

I am creating a modal window with "Ok" and "Cancel" button. How can I leave the "Ok" button greyed out if the user did not enter any information in one of the inputs?

 

Thank you.

 

// User Interface Window to get some data
UIwin = New Window( "User Input",
	Show Menu( 0 ),
	Show Toolbars( 0 ), 
	<<Modal,
	H List Box(
		V List Box(
			Panel Box( "",
					Spacer Box( size( 250, 5 ) ),
					H Center Box( Text Box( "User Input 1", <<Set Font Size( 11 ) ) ),
					H Center Box( String1 = Text Edit Box( "", Hint( "User Input 1" ), <<set width( 150 ) ) ),
					Spacer Box( size( 5, 5 ) ),
								
					H Center Box( Text Box( "User Input 2", <<Set Font Size( 11 ) ) ),
					Spacer Box( size( 5, 5 ) ),
					H Center Box( String2 = Text Edit Box( "", Hint( "User Input 2" ), <<set width( 150 ) ) ),
					Spacer Box( size( 2, 25 ) ),
				),
			),
		),
			Button Box ("OK",
			UserInput1 = String1 << get text();
			UserInput2 = String2 << get text();				
		),
		Button Box ("Cancel", UIwin),
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How to grey out OK button if user input is missing

You could use the Enable() message, like this:

 

names default to here(1);


CheckInput = function({},
	write("here");
	UserInput1 = String1 << get text();
	UserInput2 = String2 << get text();	
	if(
		(length(UserInput1) > 0 ) & (length(Userinput2) > 0), 
		bbOK << Enable(1), 
		bbOK << Enable(0)
	)
);


// User Interface Window to get some data
UIwin = New Window( "User Input",
	Show Menu( 0 ),
	Show Toolbars( 0 ), 
	<<Modal,
	H List Box(
		V List Box(
			Panel Box( "",
					Spacer Box( size( 250, 5 ) ),
					H Center Box( Text Box( "User Input 1", <<Set Font Size( 11 ) ) ),
					H Center Box( String1 = Text Edit Box( "", Hint( "User Input 1" ), <<set width( 150 ), << Set Script( CheckInput() ) ) ),
					Spacer Box( size( 5, 5 ) ),
								
					H Center Box( Text Box( "User Input 2", <<Set Font Size( 11 ) ) ),
					Spacer Box( size( 5, 5 ) ),
					H Center Box( String2 = Text Edit Box( "", Hint( "User Input 2" ), <<set width( 150 ), << Set Script( CheckInput() ) ) ),
					Spacer Box( size( 2, 25 ) ),
				),
			),
		),
			bbOK = Button Box ("OK",
			UserInput1 = String1 << get text();
			UserInput2 = String2 << get text();	
			, << Enable(0)			
		),
		Button Box ("Cancel", UIwin),
);

View solution in original post

1 REPLY 1
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How to grey out OK button if user input is missing

You could use the Enable() message, like this:

 

names default to here(1);


CheckInput = function({},
	write("here");
	UserInput1 = String1 << get text();
	UserInput2 = String2 << get text();	
	if(
		(length(UserInput1) > 0 ) & (length(Userinput2) > 0), 
		bbOK << Enable(1), 
		bbOK << Enable(0)
	)
);


// User Interface Window to get some data
UIwin = New Window( "User Input",
	Show Menu( 0 ),
	Show Toolbars( 0 ), 
	<<Modal,
	H List Box(
		V List Box(
			Panel Box( "",
					Spacer Box( size( 250, 5 ) ),
					H Center Box( Text Box( "User Input 1", <<Set Font Size( 11 ) ) ),
					H Center Box( String1 = Text Edit Box( "", Hint( "User Input 1" ), <<set width( 150 ), << Set Script( CheckInput() ) ) ),
					Spacer Box( size( 5, 5 ) ),
								
					H Center Box( Text Box( "User Input 2", <<Set Font Size( 11 ) ) ),
					Spacer Box( size( 5, 5 ) ),
					H Center Box( String2 = Text Edit Box( "", Hint( "User Input 2" ), <<set width( 150 ), << Set Script( CheckInput() ) ) ),
					Spacer Box( size( 2, 25 ) ),
				),
			),
		),
			bbOK = Button Box ("OK",
			UserInput1 = String1 << get text();
			UserInput2 = String2 << get text();	
			, << Enable(0)			
		),
		Button Box ("Cancel", UIwin),
);