1. another setHandler() question

is it possible to pass a parameter through sethandler()?

code snippet:

procedure ASL_Cancel_onClick(integer self, integer event, sequence 
params)
	closeWindow(ASL_Window)
end procedure

procedure ASL_Add_onClick(integer self, integer event, sequence params)

--	item = getIndex(ItemsAvailable_List)
--	addItem(Item_List, Products[item][2])
--	addItem(Quantity_List, Products[item][3])
--	addItem(Price_List, Products[item][4])
	
end procedure

procedure add_to_sale_list(integer self, integer event, sequence params)
integer item
atom Event
sequence title
	
	Event=params[1]
	if Event = LEFT_DOUBLECLICK  then
		item = getIndex(ItemsAvailable_List)
		title = Products[item][2] & "  " & Products[item][4] & "  " & 
Products[item][3]
		ASL_Window = createEx( Window, title, 0, Default, Default, 331, 120, 
0, 0 )
		ASL_Button1 = createEx( PushButton, "Add", ASL_Window, 40, 60, 80, 30, 
0, 0 )
		ASL_Button2 = createEx( PushButton, "Cancel", ASL_Window, 195, 60, 80, 
30, 0, 0 )
		ASL_Edit = createEx( EditText, "", ASL_Window, 110, 15, 85, 25, 0, 0 )
		setHandler( ASL_Button1, w32HClick, routine_id("ASL_Add_onClick"))
		setHandler( ASL_Button2, w32HClick, routine_id("ASL_Cancel_onClick))
		openWindow(ASL_Window, Modal)
		setFocus(ASL_Edit)
	end if
end procedure


I need to pass 'item' (integer) to the ASL_Add_onClick routine, but 
don't know if sethandler will let me, and I do not really want to make 
it a file-wide variable. If I could do the entire operation in just one 
procedure it would be even better. Hunting around the win32lib docs 
hasn't helped, any ideas?

Thank You

new topic     » topic index » view message » categorize

2. Re: another setHandler() question

----- Original Message ----- 
From: "David Davis" <gdavis at hypercon.net>
To: "EUforum" <EUforum at topica.com>
Subject: another setHandler() question


> 
> 
> is it possible to pass a parameter through sethandler()?
> 
> code snippet:
> 
> procedure ASL_Cancel_onClick(integer self, integer event, sequence 
> params)
> closeWindow(ASL_Window)
> end procedure
> 
> procedure ASL_Add_onClick(integer self, integer event, sequence params)
> 
> -- item = getIndex(ItemsAvailable_List)
> -- addItem(Item_List, Products[item][2])
> -- addItem(Quantity_List, Products[item][3])
> -- addItem(Price_List, Products[item][4])
> 
> end procedure
> 
> procedure add_to_sale_list(integer self, integer event, sequence params)
> integer item
> atom Event
> sequence title
> 
> Event=params[1]
> if Event = LEFT_DOUBLECLICK  then
> item = getIndex(ItemsAvailable_List)
> title = Products[item][2] & "  " & Products[item][4] & "  " & 
> Products[item][3]
> ASL_Window = createEx( Window, title, 0, Default, Default, 331, 120, 
> 0, 0 )
> ASL_Button1 = createEx( PushButton, "Add", ASL_Window, 40, 60, 80, 30, 
> 0, 0 )
> ASL_Button2 = createEx( PushButton, "Cancel", ASL_Window, 195, 60, 80, 
> 30, 0, 0 )
> ASL_Edit = createEx( EditText, "", ASL_Window, 110, 15, 85, 25, 0, 0 )
> setHandler( ASL_Button1, w32HClick, routine_id("ASL_Add_onClick"))
> setHandler( ASL_Button2, w32HClick, routine_id("ASL_Cancel_onClick))
> openWindow(ASL_Window, Modal)
> setFocus(ASL_Edit)
> end if
> end procedure
> 
> 
> I need to pass 'item' (integer) to the ASL_Add_onClick routine, but 
> don't know if sethandler will let me, and I do not really want to make 
> it a file-wide variable. If I could do the entire operation in just one 
> procedure it would be even better. Hunting around the win32lib docs 
> hasn't helped, any ideas?
> 
> Thank You

Without knowing all the details, can I suggest you try using the User Property
feature.

Pick a suitable control, maybe the 'Add' button itself, and define a user
property for it.

  defineUserProperty(ASL_Button1, "item", -1) -- initial value of -1.

Then when you need to assign a value to 'item' ...

  setUserProperty(ASL_Button1, "item", newvalue)

Then in the 'ASL_Add_onClick' routine do this...

  item = getUserProperty(ASL_Button1, "item")

or even 

  item = getUserProperty(self, "item")

I know this is very similar to the file-wide variable idea, but the scope of the
user property is limited to the control.

The problem with passing parameters with setHandler is that you can only pass
the *value* of the item when setHandler is called, whereas you need the value at
the time the event happens.

I might consider this functionality when I add user-defined events to win32lib.

-- 
Derek

new topic     » goto parent     » topic index » view message » categorize

3. Re: another setHandler() question

On Mon, 08 Sep 2003 03:38:48 +0000 (09/08/03 13:38:48)
, David Davis <gdavis at hypercon.net> wrote:

>
>
> Thanks again Derek, that served my needs very nicely
>
> Any chance of being able to right justify edittext boxes and lists in
> the next library version?

Don't have to. Just add WS_EX_RIGHT to the Extra Flag parameter in 
createEx(). For example...

   myFld = createEx(EditText, "", theWindow, l,t,w,h, 0, WS_EX_RIGHT)

This works for List controls too.


-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu