MapButton with a jpg file as image

EASY QUESTION . it's such a simple question that in a day of testing I couldn't solve it and not even chatgpt can help me. and looking at the max online guide I'm pretty sure that not even autodesk knows how to do it).
I would like to make a button with a jpg, simple. no strange stuff, script pages.

what's wrong with this line of code?

mapButton 'btn1' "MapButton" width:75 height:90 pos:[20,10] map:@"G:\\XXX\SCRIPT_interfaccia\SCRIPT_Library\Immagini_Tessere\STANDARD\KKK\file_0001.jpg"

grazie
love for everyone

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
SimonBourgeois's picture

Hi

It is because your are using "mapButton" which is a special kind of button that opens the map browser, if you want to create a simple button with an image you can use this:

(
	 rollout test "test"
	 (
		 button 'btn1' width:75 height:90 pos:[20,10] 
 
		 on test open do
		 (
			local image ="G:/XXX/SCRIPT_interfaccia/SCRIPT_Library/Immagini_Tessere/STANDARD/KKK/file_0001.jpg"
			btn1.images =  #(image, undefined, 1,1,1,1,1 )
		 )
	 )
	 CreateDialog test
 )

or you can use dotnet:

(
	rollout test "test"
	(
 
		dotNetControl 'btn1' "System.Windows.Forms.Button" width:75 height:90 pos:[20,10] 
 
		on test open do
		(
			local btn1ImgPath = "G:/XXX/SCRIPT_interfaccia/SCRIPT_Library/Immagini_Tessere/STANDARD/KKK/file_0001.jpg"
			local btn1Img = dotNetObject "System.Drawing.Bitmap" btn1ImgPath
			btn1.image = btn1Img
		)
	)
	CreateDialog test
)

if you choose dotnet the event handler is as follow: on btn1 click do... (use "click" instead of "pressed")

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.