#92103 - 2003-05-30 05:35 AM
Re: KiXForms Right Click
|
krabourn
Hey THIS is FUN
Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
|
This was a test script when we were talking about it. code:
Break On
$Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown" FUNCTION OnFormMouseDown If $Form.MouseButton = 2 ; Right-click fnPopup($Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY) ENDIF EndFunction
$Form.Show $Form.PrintXY(10, 10, "Form Left " + $Form.Left) $Form.PrintXY(10, 30, "Form Top " + $Form.Top) WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop
Exit 1
FUNCTION fnPopup($FormSLeft, $FormSTop) $FormS = CreateObject("Kixtart.Form") $FormS.BorderStyle = 0 $FormS.ClientWidth = 100 $FormS.ClientHeight = 35 $FormS.Top = $FormSTop + 30 $FormS.Left = $FormSLeft + 5 $FormS.ForeColor = Red $FormS.Show $FormS.Rectangle(0, 0, $FormS.ClientWidth, $FormS.ClientHeight) $btnClose = $FormS.CommandButton("Click Me", 10, 5, 80, 25) $btnClose.OnClick = "$$FormS.Hide" While $FormS.Visible $=Execute($FormS.DoEvents()) Loop ENDFUNCTION
_________________________
Kelly
|
Top
|
|
|
|
#92104 - 2003-05-30 03:28 PM
Re: KiXForms Right Click
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Kelly,
I modified your example to make it appear more like a real context menu. Hope you like it...
Break On
$Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown"
$Form.Show
WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop
Exit 1
FUNCTION OnFormMouseDown If $Form.MouseButton = 2 ; Right-click fnPopup($Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY) ENDIF EndFunction
FUNCTION fnPopup($FormSLeft, $FormSTop) $FormS = CreateObject("Kixtart.Form") $FormS.BorderStyle = 0 $FormS.ClientWidth = 100 $FormS.ClientHeight = 42 $FormS.Top = $FormSTop + 30 $FormS.Left = $FormSLeft + 5 $FormS.Line(0,0,0,$FormS.ClientHeight,"White") $FormS.Line(0,0,$FormS.ClientWidth,0,"White") $FormS.Line($FormS.ClientWidth-1,0,$FormS.ClientWidth-1,$FormS.ClientHeight,"DimGray") $FormS.Line(0,$FormS.ClientHeight-1,$FormS.ClientWidth,$FormS.ClientHeight-1,"DimGray") $btnClose = $FormS.ToolButton("Click Me", 1, 1, $FormS.ClientWidth-2, 18) $btnClose.FlatStyle = 1 $btnClose.Icon = 10 ; Green Check $btnClose.Alignment = 0 ; Right $btnClose.HotBackColor = Navy $btnClose.HotForeColor = White $btnClose.OnClick = "fnClickMe()" $bFlip = not 0 ;Separator Line $FormS.Line(2,$btnClose.Bottom+2,$FormS.ClientWidth-2,$btnClose.Bottom+2,"DimGray") $FormS.Line(2,$btnClose.Bottom+3,$FormS.ClientWidth-2,$btnClose.Bottom+3,"White") $btnClose2 = $FormS.ToolButton("Close Context", 1, $btnClose.Bottom+4, $FormS.ClientWidth-2, 18) $btnClose2.FlatStyle = 1 $btnClose2.Icon = 37 ; OpenFolder $btnClose2.Alignment = 0 ; Right $btnClose2.HotBackColor = Navy $btnClose2.HotForeColor = White $btnClose2.OnClick = "$$FormS.Hide" $FormS.Show While $FormS.Visible $=Execute($FormS.DoEvents()) Loop ENDFUNCTION
FUNCTION fnClickMe() $bFlip = not $bFlip If $bFlip $btnClose.Icon = 10 ; Green Check Else $btnClose.Icon = 9 ; Red X EndIf ENDFUNCTION
[ 30. May 2003, 17:06: Message edited by: Chris S. ]
|
Top
|
|
|
|
#92105 - 2003-05-30 03:47 PM
Re: KiXForms Right Click
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Added another "Context MenuItem."
Shawn, HorizontalAlignment doesn't seem to work.
|
Top
|
|
|
|
#92106 - 2003-05-30 04:07 PM
Re: KiXForms Right Click
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Thats looking pretty good. Could even add some icons to the left of the menuitem ... the Alignment property doesn't control the alignment of text, it controls the alignment of text in relation to the icon, so for example:
code:
$btnClose.FlatStyle = 1 $btnClose.Icon = 1 ; OpenFolder $btnClose.Alignment = 0 ; Right $btnClose.HotBackColor = Navy $btnClose.HotForeColor = White
And those menu colors look just like the real thing.
-Shawn
|
Top
|
|
|
|
#92107 - 2003-05-30 04:15 PM
Re: KiXForms Right Click
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Holly Cow!
Thanks for all the suggestions. I'll play with these ideas and get back with hopefully a useful tool...
|
Top
|
|
|
|
#92109 - 2003-05-30 05:02 PM
Re: KiXForms Right Click
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Still having fun.
|
Top
|
|
|
|
#92112 - 2003-05-30 07:00 PM
Re: KiXForms Right Click
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4549
Loc: USA
|
Exactly!
|
Top
|
|
|
|
#92113 - 2003-05-30 07:16 PM
Re: KiXForms Right Click
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Heres a really quick re-working of Chris's script (sorry, dont have postprep with me). It uses Controls Arrays as opposed to dynamically created $Variables using the EXECUTE() function. Personally, I'm a big fan of control arrays but I am sure you will hear from other Kixforms developers that use the Execute method.
{EDIT: Postprep code added by moderator Chris S.}
Break On $Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown" $Form.Show WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1 FUNCTION OnFormMouseDown Dim $Menu,$Item $Menu = "New","Open","Save","Save as...","Exit" If $Form.MouseButton = 2 ; Right-click $Item = fnPopup($Menu,$Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY) ?"Item=" $Item ENDIF EndFunction FUNCTION fnPopup($MenuStrings,$FormSLeft, $FormSTop) Dim $MenuItems[UBOUND($MenuStrings)] $FormS = CreateObject("Kixtart.Form") $FormS.BorderStyle = 0 $FormS.ClientWidth = 100 $FormS.ClientHeight = 42 $FormS.Top = $FormSTop + 30 $FormS.Left = $FormSLeft + 5 $Top = 1 For $i = 0 To UBOUND($MenuStrings) $MenuItems[$i] = $FormS.ToolButton($MenuStrings[$i], 1, $Top, $FormS.ClientWidth-2, 20) $MenuItems[$i].FlatStyle = 1 $MenuItems[$i].Alignment = 0 ; Right $MenuItems[$i].HotBackColor = Navy $MenuItems[$i].HotForeColor = White $MenuItems[$i].OnClick = "$$FormS.Tag=$i $$FormS.Hide" $Top = $Top + 20 Next $FormS.ClientHeight = $Top + 2 $FormS.Line(0,0,0,$FormS.ClientHeight,"White") $FormS.Line(0,0,$FormS.ClientWidth,0,"White") $FormS.Line($FormS.ClientWidth-1,0,$FormS.ClientWidth-1,$FormS.ClientHeight,"DimGray") $FormS.Line(0,$FormS.ClientHeight-1,$FormS.ClientWidth,$FormS.ClientHeight-1,"DimGray") $FormS.Tag = -1 $FormS.Show While $FormS.Visible $=Execute($FormS.DoEvents()) Loop $fnPopup = $FormS.Tag ENDFUNCTION FUNCTION fnClickMe() $bFlip = not $bFlip If $bFlip $btnClose.Icon = 10 ; Green Check Else $btnClose.Icon = 9 ; Red X EndIf ENDFUNCTION
[ 30. May 2003, 19:29: Message edited by: Chris S. ]
|
Top
|
|
|
|
#92117 - 2003-06-02 03:45 AM
Re: KiXForms Right Click
|
Bryce
KiX Supporter
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
i get no love thses days http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=13;t=000571#000000
code:
Break On $Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown" $Form.Show WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1 FUNCTION OnFormMouseDown Dim $Menu,$Item $Menu = "New","Open","Save","Save as...","Exit" If $Form.MouseButton = 2 ; Right-click $Item = popup($Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY,$menu) ?"Item=" $Item ENDIF EndFunction
function popup($x,$y,$dataarray) dim $o_popup, $dataaray, $x, $y, $i, $objectdata, $width, $lastwidth, $oldobject, $top, $close $o_popup = createobject("Kixtart.form") $o_popup.border = 0 $o_popup.location = $x,$y
$blue = $o_popup.rgb(50,0,238) $black = $o_popup.rgb(0,0,0)
$close = $o_popup.label("X",0,0,0,0) $close.width = $close.width $close.onmouseover = "o_popupmouseover($$dataarray,-1,$$black,$$black)" $close.onclick = "$$o_popup=0 $$popup=-1"
for $i = 0 to ubound($dataarray) $objectdata = $dataarray[$i] if $i > 0 $oldobject = $i-1 $ = execute("$$top = $$$oldobject.height + $$top") else $top = $close.height endif $ = execute('$$$i = $$o_popup.label($$objectdata,0,0,0,0)') $ = execute("$$$i.top=$$top") $ = execute("$$$i.width = $$$i.width+5") $ = execute("$$$i.onmousemove = 'o_popupmouseover($$$dataarray,$$i,$$blue,$$black)'") $ = execute("$$$i.onclick = '$$$$popup = $i $$$$o_popup=0'")
$ = execute("$$width = $$$i.width") if $width > $lastwidth $lastwidth = $width+6 endif if $i = ubound($dataarray) $ = execute("$$top = $top+$$$i.height+($$$i.height/2)") endif next
$o_popup.height = $top $o_popup.width = $lastwidth
$close.left = $lastwidth - $close.width-10 $o_popup.show While $o_popup.Visible $=Execute($o_popup.DoEvents()) Loop endfunction
function o_popupMouseOver($array,$pointer,$oncolor, $offcolor) for $i = 0 to ubound($array) if $i = $pointer $ = execute("$$$i.forecolor = $$blue") else $ = execute("$$$i.forecolor = $$black") endif next endfunction
|
Top
|
|
|
|
#92119 - 2003-06-02 06:27 PM
Re: KiXForms Right Click
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Since the textalignment for ToolButton is not implemented yet, a work-around is to use a fixed-length font and pad the "menuitems" with spaces.
Break On $Form = CreateObject("Kixtart.Form") $Form.Size = 400, 400 $Form.Center $Form.ForeColor = Blue $Form.OnMouseDown = "OnFormMouseDown" $Form.Show WHILE $Form.Visible $=Execute($Form.DoEvents()) Loop Exit 1 FUNCTION OnFormMouseDown Dim $Menu,$Item $Menu = "New ","Open ","Save ","Save as...","Exit " If $Form.MouseButton = 2 ; Right-click $Item = fnPopup($Menu,$Form.Left + $Form.MouseX, $Form.Top + $Form.MouseY) ?"Item=" $Item ENDIF EndFunction FUNCTION fnPopup($MenuStrings,$FormSLeft, $FormSTop) Dim $MenuItems[UBOUND($MenuStrings)] $FormS = CreateObject("Kixtart.Form") $FormS.BorderStyle = 0 $FormS.ClientWidth = 100 $FormS.ClientHeight = 42 $FormS.Top = $FormSTop + 30 $FormS.Left = $FormSLeft + 5 $Top = 1 For $i = 0 To UBOUND($MenuStrings) $MenuItems[$i] = $FormS.ToolButton($MenuStrings[$i], 1, $Top, $FormS.ClientWidth-2, 20) $MenuItems[$i].FontName = "Lucida Console" ;"Courier New" $MenuItems[$i].FlatStyle = 1 $MenuItems[$i].Alignment = 0 ; Right $MenuItems[$i].HotBackColor = Navy $MenuItems[$i].HotForeColor = White $MenuItems[$i].OnClick = "$$FormS.Tag=$i $$FormS.Hide" $Top = $Top + 20 Next $FormS.ClientHeight = $Top + 2 $FormS.Line(0,0,0,$FormS.ClientHeight,"White") $FormS.Line(0,0,$FormS.ClientWidth,0,"White") $FormS.Line($FormS.ClientWidth-1,0,$FormS.ClientWidth-1,$FormS.ClientHeight,"DimGray") $FormS.Line(0,$FormS.ClientHeight-1,$FormS.ClientWidth,$FormS.ClientHeight-1,"DimGray") $FormS.Tag = -1 $FormS.Show While $FormS.Visible $=Execute($FormS.DoEvents()) Loop $fnPopup = $FormS.Tag ENDFUNCTION
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 918 anonymous users online.
|
|
|