Notifications
Clear all

[Closed] Combobox: edit text when "ENTER" pressed

TomDeVis
i don’t understand what you want to achieve. do you want to give a user some interface to add/remove custom parameters? or do you want to rename on the fly already existent custom parameters?
try to explain why you need it, maybe it helps me to get what you need.

@starsyil: thanks a lot, that was exaclty what I needed, although I believe I could have written in a much shorter way I’ve finally managed to get it to a workeable version!!!

@DenisT Thanks for all your help, I really did my best to describe what I needed. I currently have it finished with some minor tweaks that I could change.
The main problem was that I needed the wire paramater controller to be accesible so it makes sence when you access it through the wire parameters.

Thank you everyone for all your help! I’ve learned a lot ! But really A LOT !

In attachement at what state it currently is. (had to zip it to be able to upload it)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i can’t say that you are going in right direction but the code at least might be shorter:


-- Add Spinner-Sliders v1.0.0
-- Author: Tom De Vis
-- Website:  http://tomdevis.blogspot.com/ 

intAmount = 1
intNumberClicked = 1

arrName = #()
arrMin = #()
arrMax = #()
arrDefault = #()

arrNewSettings = #()

rollout rolAddSpinnerSliders "Add Spinner Sliders" width:259 height:60
(
	button btnAdd "Add Spinner-sliders" pos:[156,6] width:100 height:20 enabled: false
	label lbl1 "Amount SpinnerSliders:" pos:[6,8] width:120 height:16
	dropdownList DDL_amount "" pos:[117,4] width:37 height:21 items:#("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")

	dotNetControl lvObject "System.Windows.Forms.ListView" pos:[7,33] width:246 height:194
	
	-- <<<<<<<<<<< FUNCTIONS  >>>>>>>>>>>>
	function InitListView lView=
	(
		lView.gridlines = true
		lView.view = (dotNetClass "System.Windows.Forms.View").Details
		lView.fullRowSelect = true

		local columnNames = #("Name", "Min","Max" , "Default")
		
		for i in columnNames do
		(
			lView.columns.add i
		)
	)
	function fnMakeArray =
	(
		arrName = #()
		arrMin = #()
		arrMax = #()
		arrDefault = #()
		for k=1 to intAmount do
		(
			append arrName ("temp" + k as string)
			append arrMin 0
			append arrMax 100
			append arrDefault 0
		)
	)
	fn addjustListHeight= 
	(
			local theHeight = (intAmount * 17) + 35
			if theHeight < 500 then
			(
				lvObject.height = theHeight 
				rolAddSpinnerSliders.height = theHeight +25
			)
			else
			(
				lvObject.height = 500
				rolAddSpinnerSliders.height = 510
			)
	)
	function FillListView lView =
	( 		
		local lvItemList = #()
		
		for i=1 to intAmount do 
		(
			lvItem = dotNetObject "System.Windows.Forms.ListViewItem" arrName[i] 
			lvItem.subitems.add (arrMin[i] as string)
			lvItem.subitems.add (arrMax[i] as string) 
			lvItem.subitems.add (arrDefault[i] as string)
			
			append lvItemList lvItem
		)
		lView.Items.Clear()
		lView.Items.Addrange lvItemList
	)

	function SetSpinnerSliders modi =  
	(
		ss = stringstream ""
		format "ca = attributes SpinnerSliderControl
" to:ss
		format "(
" to:ss
		format "	parameters params rollout:params
" to:ss
		format "	(
" to:ss
		
		for i=1 to intAmount do 
		(
			format "	% type:#float default:% ui:(ctrlSpinner%,ctrlSlider%)
" arrName[i] arrDefault[i] i i to:ss
		)
		
		format "	)
" to:ss
		format "	rollout params \"Controls\"
" to:ss
		format "	(
" to:ss
		
		for i=1 to intAmount do 
		(
			format "		spinner ctrlSpinner% \"\" range:[%,%,%] align:#right width:40
" i arrMin[i] arrMax[i] arrDefault[i] to:ss
			format "		slider ctrlSlider% \"%\" range:[%,%,%] width:100 offset:[0,-25]
" i arrName[i] arrMin[i] arrMax[i] arrDefault[i] to:ss
		)
		format "	)
" to:ss
		
		format ")
" to:ss
		
		custAttributes.add modi (execute (ss as string))
	)
	rollout rollout_Rename "Rename to:" width:180 height:165
	(
		label lbl10 "____________" pos:[10,13] width:150 height:15
		label lbl_OldSettings "New Settings:" pos:[13,9] width:155 height:13
		button btn_Ok "Ok" pos:[10,135] width:80 height:24 toolTip:"Press to rename."
		button btn_Cancel "Cancel" pos:[90,135] width:80 height:24 toolTip:"Press to cancel renaming."	
		
		edittext txt_Name "New Name:  " pos:[13,35] width:154 height:17
		edittext txt_Min "New Min:	  " pos:[12,60] width:154 height:17
		edittext txt_Max "New Max:	 " pos:[13,85] width:154 height:17
		edittext txt_Default "New Default:" pos:[12,110] width:154 height:17
		
		on rollout_Rename open do
		(
			txt_Name.text = arrName[intNumberClicked] as string
			txt_Min.text = arrMin[intNumberClicked] as string
			txt_Max.text = arrMax[intNumberClicked] as string
			txt_Default.text = arrDefault[intNumberClicked] as string
		)
		on btn_Ok pressed do
		(
			arrName[intNumberClicked] = txt_Name.text
			arrMin[intNumberClicked] = txt_Min.text as integer
			arrMax[intNumberClicked] = txt_Max.text as integer
			arrDefault[intNumberClicked] = txt_Default.text as integer
			
			FillListView lvObject
			
			destroyDialog rollout_Rename
		)
		on btn_Cancel pressed do
		(
			destroyDialog rollout_Rename
		)
	)
	
	on rolAddSpinnerSliders open do
	( 
		InitListView lvObject
		addjustListHeight()
	)
	on DDL_amount selected i do
	(
		intAmount = i
		fnMakeArray()
		addjustListHeight()
		FillListView lvObject
		btnAdd.enabled = true
	)
	on lvObject ItemActivate do
	(
		intNumberClicked = lvObject.FocusedItem.Index + 1
		createDialog rollout_Rename
	)
	on btnAdd pressed do
	(
		for o in Selection do
		(
			addModifier o (modi = emptyModifier() )
			SetSpinnerSliders modi		
		)
	)
)
createDialog rolAddSpinnerSliders

Page 2 / 2