Page 1 of 2 12>
Topic Options
#92100 - 2003-05-29 06:47 PM KiXForms Right Click
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Does anyone know if it is possible for KiXForms to support a right click and then show a submenu of options/commands to act on?

As an example, in Explorer, you can select mulitiple items, right click and then click on copy.

Idealy, I would like have a listview of items. Be able to muliselect items within the list, and then be able to right click and a submenu of items comes up to act on those selected.

Top
#92101 - 2003-05-29 07:00 PM Re: KiXForms Right Click
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See for example Kixforms: Which mouse button was clicked? . There's also been a script that demonstrated a true context-menu system, just can't find it right now as I don't remember what the name was.
_________________________
There are two types of vessels, submarines and targets.

Top
#92102 - 2003-05-29 07:01 PM Re: KiXForms Right Click
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Theres no support for builtin context menus off the ListView yet - although I believe that member krabourn did try to make a custom jobby using a popup form that behaved like a menu. Think that Jim (jtokach) was also playing with this.

The other thing you might do is simply use the regular-old pull-down menu on the form to "act" on the SelectedItems in the ListView ... or use a stand-alone Button or ToolButton along the top of the form. Thats what I usualy do.

-Shawn

Top
#92103 - 2003-05-30 05:35 AM Re: KiXForms Right Click
krabourn Offline
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. Offline
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 = 400400
$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"11$FormS.ClientWidth-218)
        $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-218)
        $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. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Added another "Context MenuItem." [Wink]

Shawn, HorizontalAlignment doesn't seem to work.

Top
#92106 - 2003-05-30 04:07 PM Re: KiXForms Right Click
Shawn Administrator Offline
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 Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
[Eek!] Holly Cow! [Eek!]

Thanks for all the suggestions. I'll play with these ideas and get back with hopefully a useful tool...

Top
#92108 - 2003-05-30 04:45 PM Re: KiXForms Right Click
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Added a separator line to the example.
Top
#92109 - 2003-05-30 05:02 PM Re: KiXForms Right Click
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Still having fun. [Wink] [Razz]
Top
#92110 - 2003-05-30 06:44 PM Re: KiXForms Right Click
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
okay... lets say in the above example you want the subcontext menu items 1 - 10. Is it possible to do something like...

for $button = 1 to 10
CreateButton
next

Also, if the above is possible, how would you know what button is pressed?

Top
#92111 - 2003-05-30 06:59 PM Re: KiXForms Right Click
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You mean like create a dynamic menu - displaying strings from say, an array of menuitem strings ?
Top
#92112 - 2003-05-30 07:00 PM Re: KiXForms Right Click
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Exactly! [Razz]
Top
#92113 - 2003-05-30 07:16 PM Re: KiXForms Right Click
Shawn Administrator Offline
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 = 400400
$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-220)
     $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
#92114 - 2003-05-30 11:53 PM Re: KiXForms Right Click
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Thanks! Your example is exactly what I was looking for...

I've been playing with the alignment and would like to align left. When I tried changing the .alignment=1 it didn't appear that anything changed. For my purposes I do not need an icon on the left either... is the space that the icon occupies required?

I also dug around on KiXForms.com but did not find any docs on Toolbutton... am I missing something.

Thanks again.

Top
#92115 - 2003-06-01 10:10 PM Re: KiXForms Right Click
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
As mentioned somewhere before (kforg I think) the .Alignment Property for ToolButton is relative to its Icon ...

[ 01. June 2003, 22:17: Message edited by: Jochen ]
_________________________



Top
#92116 - 2003-06-01 10:14 PM Re: KiXForms Right Click
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
So ... try this :

(Caution the 'nul' Icon changes (still) from release to release)

this is for the latest beta 2 (build 40)


break on

$f = createobject("KiXtart.Form")


$b = $f.ToolButton("LeftAligned",$f.ClientWidth/2-40,$f.ClientHeight/2-10,80,20)
$b.Icon = 60
$b.Alignment = 1

$f.Show

while $f.visible
$ = execute($f.DoEvents)
loop
_________________________



Top
#92117 - 2003-06-02 03:45 AM Re: KiXForms Right Click
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
i get no love thses days [Razz]
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
#92118 - 2003-06-02 03:17 PM Re: KiXForms Right Click
krabourn Offline
Hey THIS is FUN
*****

Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
WOW! [Cool] Sorry for the slow response. I had a funeral in Indiana to go to this weekend.

I like what you have come up with. When Shawn adds mouse events to ListView that can tell me row and column, I will definatly start with one of these.
_________________________
Kelly

Top
#92119 - 2003-06-02 06:27 PM Re: KiXForms Right Click
Chris S. Offline
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 = 400400
$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-220)
     $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
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.197 seconds in which 0.146 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org