Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Dec 17, 2017 12:51 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: ContextualMenu Editing?
PostPosted: Tue Mar 05, 2013 11:00 am 
Offline

Joined: Fri Jun 05, 2009 4:54 pm
Posts: 484
Location: London, England
Hi,
does anyone know why the EDIT case of the ContextualMenu below doesn't work?

The "Add" and "Delete" work fine, but the "Edit" case does nothing :(

Select Case hititem.text
case "Add a New Statistic"
list.AddRow ""
list.EditCell(list.LastIndex,0)
case "Edit the Selected Statistic"
Dim row,column as Integer
row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left,System.MouseY - Me.Top - Self.Top)
column=Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left,System.MouseY - Me.Top - Self.Top)
Me.CellType(row,column)=ListBox.TypeEditable
Me.EditCell(row,column)
case "Delete the Selected Statistic"
List.RemoveRow(List.ListIndex)
End select

Return True


Thanks

_________________
RealStudio Professional Edition 2012 r2
Developing on OS X 10.8 (Mountain Lion)
Deploying on Windows XP / Vista / 7 / 8


Top
 Profile  
Reply with quote  
 Post subject: Re: ContextualMenu Editing?
PostPosted: Tue Mar 05, 2013 2:28 pm 
Offline
User avatar

Joined: Wed Feb 01, 2012 3:06 pm
Posts: 68
I'm very new to this but had problem computing row/column from xy in the ContextualMenuAction Event.

I computed the row/column in the ContructContextualMenu Event and passed the values in the hitItem.tag field.

Hopefully someone else has a better explanation for you.

Ron Bower
Ellicott City, MD

_________________
Ron Bower
Ellicott City, MD


Top
 Profile  
Reply with quote  
 Post subject: Re: ContextualMenu Editing?
PostPosted: Tue Mar 05, 2013 2:50 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
The ContextualMenuAction event is raised only after the user has moved their mouse to click on the context menu (or they may not have used the mouse at all since many keyboards have a "context menu" key.)

Follow RonBower's suggestion using the X As Integer and Y As Integer parameters given to the ConstructContextualMenu event to calculate the Row and Column.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: ContextualMenu Editing?
PostPosted: Wed Mar 06, 2013 1:39 am 
Offline

Joined: Fri Jun 05, 2009 4:54 pm
Posts: 484
Location: London, England
Hi,
I guess the answers you both kindly gave me are a bit confusing, if you are a stupid newbie :(
I don't quite understand the part about - passing the value on to the hititem.tag?


Do you mean like this (probably not):

Edit the Selected Statistic.tag=(row,column)


If so where would I put this line of code, and how would I then attach the tag result to the actual action to perform????


Any code examples anywhere, whereby I could read, digest, and learn from?

Hellllllllllllp :(

_________________
RealStudio Professional Edition 2012 r2
Developing on OS X 10.8 (Mountain Lion)
Deploying on Windows XP / Vista / 7 / 8


Top
 Profile  
Reply with quote  
 Post subject: Re: ContextualMenu Editing?
PostPosted: Wed Mar 06, 2013 2:10 am 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
The Tag property of the MenuItem is a Variant, which means it can be anything. Maybe the quickest way to store two values would be as a Pair object.

e.g.

Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
Dim row, col As Integer
row = Me.RowFromXY(X, Y)
col = Me.ColumnFromXY(X, Y) 'compute the row and column

Dim theCell As New Pair(row, col)
Dim item As New MenuItem("Edit the Selected Statistic")
item.Tag = row:column 'stuff the row/column into a Pair using the ":" operator
base.Append(item)
Return True
End Function

and then
Function ContextualMenuAction(hitItem as MenuItem) As Boolean
Dim tag As Pair = hitItem.Tag 'retrieve the tag
Dim row, column As Integer
row = tag.Left
column = tag.Right
'etc...
End Function

_________________
Boredom Software


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group