Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 16, 2018 4:14 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Jan 31, 2013 11:03 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
When creating objects on a canvas, how do you select the object by clicking it. If many objects overlap on the canvas, the bottom-most object gets selected rather than the top-most (object being clicked).

Test:
1) Add a NavigationBar and a Button
2) drag the button over the navigationbar
3) click the button...and the navigationbar gets selected?!?

So... how do you select the "object being clicked"?

At the moment, I'm selecting objects from the Control list and setting Top/Left property values...would like to be able to click and drag them around without activating the bottom-most objects :-(

Download pre-beta test environment:
(Windows, Mac (Intel & Intel Carbon), Linux)
http://realdevspot.com/ibuilder/

About: If you wish to test building an app, add a button and a navigationbar, set the properties of both... and be sure to add an "appname" under the app tab...second screen before pushing build... ibuilder will generate gcc code and makefile to build native ios apps without using xcode ;-)
**Note: All other ios controls were not added in the pre-beta test environment and the code window has been disabled...this is for canvas object test example only! This project is for internal use ONLY and will not be for the public...The object manipulation classes for the Canvas Control will be open-source once completed (can be used to build puzzle games or greeting-card apps :-))

Simulanics iBuilder (beta) Screenshot:
Image

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Last edited by simulanics on Fri Feb 01, 2013 12:10 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Jan 31, 2013 11:36 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
In your code that detects clicks, move the clicked object to the bottom of the list (I'm assuming an array.) This way, the last object in the array will always be the object most recently clicked, and the topmost object overlapping a point will be the one farthest down the array matching those coordinates.

Objects can be moved backwards and forwards in the array to reflect which objects are on top of which; moving an object to the end of the array would bring the object to the top.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Jan 31, 2013 11:51 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Currently I'm using the following method...how would I apply this technique...

Function MouseDown(X As Integer, Y As Integer) As Boolean
// Find the object that is where the user just clicked

mSelected = False

For Each m As iosObject In mCanvasObjects
If X >= m.Left And X <= m.Right And _
Y >= m.Top And Y <= m.Bottom Then
SelectedObject = m

Return True
End If
Next

DeselectAll
End Function


selectedobject is a computed property.its set is

Set
Dim i as Integer
DeselectAll
i = -1

For Each m As iosObject In mCanvasObjects
If m Is value Then
i = i + 1
m.Selected = True

End If
Next


mSelectedObject = value

ObjectSelected(value)

Invalidate(False)
End Set


I have sent you a link to the object classes to take a look at :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Fri Feb 01, 2013 12:18 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
I've attempted to read the array backwards which works as such


mSelected = False

Dim b as integer = mCanvasObjects.Ubound
Dim m as CanvasObject
Dim i as integer

for i = 0 to mCanvasObjects.Ubound
m = mCanvasObjects(mCanvasObjects.Ubound - i)
If X >= m.Left And X <= m.Right And _
Y >= m.Top And Y <= m.Bottom Then
SelectedObject = m

Return True
End If

next i

DeselectAll


but is this an inefficient method? I'd like to be able to add a contextual menu to "bring forward" "send back" so I'd need to get the parent index of the control arrayed under the selected control as well :-/ perhaps comparing the x,y of all controls in the array and creating an array of controls in this index by order and "swapping" their order?

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Fri Feb 01, 2013 12:25 am 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Use an index in your For...Next loops to search the objects array sequentially. Using For Each...Next is less useful when dealing with something you should treat like a stack. Use the array like a numbered list rather than a unordered group of objects.

e.g.
Function MouseDown(X As Integer, Y As Integer) As Boolean
// Find the object that is where the user just clicked

mSelected = False

For i As Integer = UBound(mCanvasObjects) DownTo 0 'Use an index
Dim m As iosObject = mCanvasObjects(i)
If X >= m.Left And X <= m.Right And _
Y >= m.Top And Y <= m.Bottom Then
mCanvasObjects.Remove(i) 'remove from its place in the list
mCanvasObject.Append(m) 'move it to the end

Return True
End If
Next
DeselectAll
End Function


You can then handle painting each object in proper order (back to front) by looping over the array again, but in reverse order.

Edit to add:
The initial ordering of the list is up to you. In your object classes the order is never changed unless an object is destroyed. Since For Each loops are done sequentially by RB anyway, the order in which objects are "found" in the array via For Each is the order in which they were created. So, the "older" object always comes first.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Feb 07, 2013 5:02 am 
Offline

Joined: Mon Nov 03, 2008 6:36 am
Posts: 477
Location: Italia > Milano > Solaro
Link demo simulator...

_________________
REALStudio
Custom controls and classes for RealStudio ( no plugin )
http://www.ivanomonti.eu


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Feb 07, 2013 9:14 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
ivanomonti wrote:
Link demo simulator...


Due to RS licensing I cannot link the actual simulator coded in REALbasic...I can link the .NET and visual basic versions if needed.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Selecting Objects in a Canvas (iOS iBuilder)
PostPosted: Thu Feb 07, 2013 10:03 am 
Offline

Joined: Mon Nov 03, 2008 6:36 am
Posts: 477
Location: Italia > Milano > Solaro
simulanics wrote:
ivanomonti wrote:
Link demo simulator...


Due to RS licensing I cannot link the actual simulator coded in REALbasic...I can link the .NET and visual basic versions if needed.



I use realbasci dotnet and I'd like to see if the work is not a problem.

_________________
REALStudio
Custom controls and classes for RealStudio ( no plugin )
http://www.ivanomonti.eu


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 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