Notifications
Clear all

[Closed] edittext ui

I made this simpal rollout…
you can pick a bit map and it will display it in the edittex …
1-I want to display the “Select a Bitmap” at the start when no bitmap is selected.
2-I want it to remember and display the last file when i cancel the “selectBitMap” window.
Now if i cancel it ,it`s erasing the last file in the edittex.

try(destroyDialog rlt_main)catch()

rollout rlt_main "" width:315
(
	
	edittext edt1 "Bitmap:" pos:[11,50] width:300 height:20 readonly:true 
	button img_browse "..." pos:[317,50] width:20 height:20
	
	on img_browse pressed do
	(
		img = selectBitMap caption:"Select a Bitmap"
		img_path= img as string  
		edt1.text=img_path
		edt1.text=replace img_path 1 7 ""
		if img == undifine then
			-- When i cancal the selectBitMap window then img == undifine
			--I want it to remember the last img that was loaded.
		(
			edt1.text = "Select a Bitmap"
		)
	)
	)

createDialog rlt_main 350 100 
2 Replies

You can use a local variable for this:


try(destroyDialog rlt_main)catch()

rollout rlt_main "GET BITMAP" width:315
(
	[B]local defaultText = "Select a Bitmap"[/B]
	
	edittext edt1 "Bitmap:" [B]text:defaultText [/B]pos:[11,50] width:300 height:20 readonly:true 
	button img_browse "..." pos:[317,50] width:20 height:20
	
	on img_browse pressed do
	(
		img = selectBitMap caption:"Select a Bitmap"
		if img != undefined do [B](edt1.text = defaultText = img.filename)[/B]
	)
)

createDialog rlt_main 350 100 


By the way, you can access the name of the bitmap through its ‘.filename’ property.

Great! thanks