Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Buttons - Graphics 2.0
Started by jack95 Nov 26 2013 02:21 PM

12 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

Since G2, buttons can no longer be treated like groups by using button parents. This broke a ton of my visuals.

 

barStamp = display.newImageRect( someButton, "images/SomeImage.png", 90, 24 ) -- broken

 

Is there any way to moor graphics to buttons anymore?



[TOPIC: post.html]
#2

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

Just a wild guess here, but have you tried someButton.group ?

[TOPIC: post.html]
#3

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

I have never heard of that. I tried it and it didnt work. Nor did someButton._view



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,615 posts
  • Enterprise

What type of object is someButton?

 

Rob



[TOPIC: post.html]
#5

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

someButton is a widget.ButtonWidget



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,615 posts
  • Enterprise

widget.newButton was never intended to be a group.  It is an individual button to trigger one task.  If it worked as a group, you were lucky.  The main change with G2.0 is the switch to containers instead of groups for some objects, but that should have not impacted internal data structures.

 

Rob



[TOPIC: post.html]
#7

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

widget.newButton was never intended to be a group. 

 

I got that. That's not the point. How are you supposed to move around groups of images in G2?

 

I have a button, it receives an onEvent begin with 4 dynamic images on it (now on a parent group). How am I supposed to move those as 1? Scale those as 1? Transition the group/container? Nope. That doesn't work.

 

Without a way to bake images together in an element that can receive events, Corona has effectively been gutted of base 2d functionality.

 

I see Snapshots can do runtime composition. If they functioned as documented (not my experience) I still have to wire event listeners to them. I hope I can.



[TOPIC: post.html]
#8

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,733 posts
  • Enterprise

Is there any specific reason you're using a widgetButton instead of creating a normal displayGroup and putting your images inside that group?

[TOPIC: post.html]
#9

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

Because the group needs to be moveable. As a group. Dropping images into a display group limits what you can do, in many ways.

You cannot move the group. The group cannot receive drag and drop/touch related events. Snapshots can be moved.

 

I'll trade G1's more masking and more textures (to replicate certain effects) and unpredictable eventing over the loss of scaling and moving groups (via buttons).



[TOPIC: post.html]
#10

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,615 posts
  • Enterprise

Group's are  movable.  They have a .x and .y and can be moved just like anything else.  And as far as touch handlers, you can.  You can either assign a touch handler to the group in which case the touch fall through to all objects in the group, or if you need to touch empty space inside the group, then you can put an invisible rect the size of the area that needs touched and put the touch handler on it after setting the rect's .isHitTestable to true.

 

Rob



[TOPIC: post.html]
#11

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

Touch events normally do not fall through buttons in G2.

 

That may not be the only widget. In G1, buttons that were disabled also prevented all event propagation.

 

You can add a tapListener and a touchListener to a group or a button in that group.

Only tap is recognized on the button and touch never falls through from the button, enabled or not.

 

It's so hard to try every possible scenario.



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,615 posts
  • Enterprise

Widget buttons consume touch events and generate release, event and press events depending on options you pass.  The touch event is handled by the object and will not propagate on.  It doesn't look like we mess with the tap event that is also generated so that will fall through.

 

This should be no different between G1 and G2.

 

Rob



[TOPIC: post.html]
#13

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 198 posts
  • Corona SDK

In addition to groups having X and Y (thanks for the correction), when they are an event.target, they lose those values as event.target

local mygroup = display.newGroup()

mygroup:insert(buttonAt10x20y)

print(mygroup.x,mygroup.y) -- outputs 10,20

mygroup:addEventListeners("touch",function(e)

    print(e.target.x,e.target.y) -- outputs 0,0

end)

which is why I thought that. If you have a button as your largest object in the group, you probably lose the ability to detect touch events. You can't forward those press/release/event from the button so....oh well.




[topic_controls]
[/topic_controls]