cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mat-ski
Level III

Modal Buttons with non-standard text

Hi, I am trying to write a modal that uses non standard text for the buttons. That is, according to the documentation one button with the text OKYesNo, or Cancel is required as a way to close the modal. In this case I have a couple of modals where instead of "OK" I have "Continue" and instead of "Cancel" I have "Not now". I see that according to the documentation you can do something like:

 

acknowledgeButton = Button Box( acknowledgeText, acknowledgeButton << Close Window ),

 

In order to use a button with a different text to close the modal. The problem is that the resulting behavior is a bit strange. Specifically, when clicked, the button disappears, but there is a delay before the modal is dismissed so for about half a second you are still seeing the modal, just without the button. Is there something that I can do to get the standard "OK"/"Cancel" behavior where the modal is immediately dismissed on click?

 

Full code for my modal:

 

Names Default To Here( 1 );

simpleMessageModal = Function( {title, message, acknowledgeText},
	{Default Local}, 

	result = Associative Array();

	modal = New Window( title,
		<<Modal,
		Border Box( Left( MODAL_PADDING ), Right( MODAL_PADDING ),
			V List Box(
				Spacer Box( size( MODAL_WIDTH, SECTION_START_SPACING ) ),
				H Center Box( Text Box( message ) ),
				Spacer Box( size( MODAL_WIDTH, SECTION_END_SPACING ) ), 

			), 

		),
		H List Box(
			Spacer Box(),
			acknowledgeButton = Button Box( acknowledgeText, acknowledgeButton << Close Window ),
			// Modals require at least one button with the text "OK", "Yes", "No", and will insert
			// one if there is no such button present, so we insert one and make it invisible.
			Button Box( "OK", <<Visibility( "collapse" ) ),

		), 

	);
	
	confirmed = modal != {Button( -1 )};

	Return( confirmed );
);

 

Edit: more context info:
MacOS 13.3.1, 32 GB RAM

2.6 GHz 6-Core Intel Core i7

JMP 17

 

1 ACCEPTED SOLUTION

Accepted Solutions
mat-ski
Level III

Re: Modal Buttons with non-standard text

In case anyone else comes across this and has the same problem:

 

I saw this post in the "recommendations" section of my post and decided to try that. Specifically my code is:

 

	invisibleOkButton = Button Box( "OK", <<Visibility( "collapse" ) );
	button = Button Box( buttonText, invisibleOkButton << Click );


Which resulted in behavior matching the standard "OK" button.

I'm not 100% sure that this is the reason for the delay between button press and modal disappearance, but in this case pressing the button starts a network request, and the delay appears to match that timing (i.e. press button -> button disappears -> network request runs -> request finishes -> modal disappears). So that may explain why the delay does not always manifest, since it would be too fast to see if it is not waiting for the network request or something similarly slow.

View solution in original post

5 REPLIES 5
mat-ski
Level III

Re: Modal Buttons with non-standard text

To add, I got this from the documentation here: https://www.jmp.com/support/help/zh/15.2/index.shtml#page/jmp/construct-a-modal-window.shtml

 

In addition to the behavior mentioned, I also hear an error chirp when I click the "Continue" button before it dismisses the modal.

txnelson
Super User

Re: Modal Buttons with non-standard text

Running on Windows 11, with a I7-9700K processor and 32 gigs of RAM, I experience no delay in the window closing after clicking on the button.

Jim
mat-ski
Level III

Re: Modal Buttons with non-standard text

Do you happen to get any error chirp?

 

I added system info about but to copy here as well:

MacOS 13.3.1, 32 GB RAM

2.6 GHz 6-Core Intel Core i7

JMP version 17

txnelson
Super User

Re: Modal Buttons with non-standard text

No

Jim
mat-ski
Level III

Re: Modal Buttons with non-standard text

In case anyone else comes across this and has the same problem:

 

I saw this post in the "recommendations" section of my post and decided to try that. Specifically my code is:

 

	invisibleOkButton = Button Box( "OK", <<Visibility( "collapse" ) );
	button = Button Box( buttonText, invisibleOkButton << Click );


Which resulted in behavior matching the standard "OK" button.

I'm not 100% sure that this is the reason for the delay between button press and modal disappearance, but in this case pressing the button starts a network request, and the delay appears to match that timing (i.e. press button -> button disappears -> network request runs -> request finishes -> modal disappears). So that may explain why the delay does not always manifest, since it would be too fast to see if it is not waiting for the network request or something similarly slow.