I created a button class which is version of IconicButton (by cutting and pasting) that does extra things that I need. One of the things that I do is expand the size of my button (actually a collection of my buttons) when running an application that uses it. When I do so only a small area of near the top left corner of my button seems to have focus so then if I click on that area the button works but otherwise it does not.
When I click within my botton's working area <MyButton>>handleEvent: anEvent> is called by <MouseOverHandler>>processMouseOver: anEvent>.
When my button does not work the method <handleEvent: anEvent> is not called because, I believe, the portion of my button that was clicked does not have focus. Note that when my button size is expanded it's position is also changed because other morphs have also expanded but this expansion does not seems to cause confusion as to where the button is because the working focus area remains in the same part of my button. But there appears to be confusion as to the size of my button and its focus area.
Debugging this is a pain. When I set a break point in <MyButton>>handleEvent: anEvent> the emergency handler pops up. when I do a <revert> I get my stack with <MyButton>>handleEvent: anEvent> at the top of the stack. But I have gathered little useful information by looking at this stack. The only solution I can think of is to discard by button (buttons) and reinstantiate them every time they need to be resized.
Is there something that I should be setting when I resize my button so that it's focus area is correct?
Is discarding my buttons and reinsantiating them the only solution?
Any help or insight appreciated.
Ralph Boland
Hi Ralph,
can you file-out and share your version of the IconicButton class?
Morph >> #handleEvent: is too low-level for your use case. You should only overwrite/implement #handlesMouseDown: and #mouseDown:, for example.
Seems to me that the icon in your button is bigger than your button. Only the button/owner gets the events here. For example, if you do this, it gets tricky:
button := IconicButton new. button labelGraphic: (MenuIcons homeIcon scaledToSize: 100@100). button extent: 50@50.
...because the button is smaller than its icon.
What you can try is either this:
button clipSubmorphs: true.
...to see the actual bounds of the owner. Or you can use a PluggableButton:
pbutton := PluggableButtonMorph new. pbutton action: #showln:. pbutton model: Transcript. pbutton arguments: #(42). pbutton label: (MenuIcons homeIcon scaledToSize: 100@100) asMorph. pbutton extent: 50@50.
Best, Marcel Am 25.10.2017 05:58:10 schrieb Ralph Boland rpboland@gmail.com: I created a button class which is version of IconicButton (by cutting and pasting) that does extra things that I need. One of the things that I do is expand the size of my button (actually a collection of my buttons) when running an application that uses it. When I do so only a small area of near the top left corner of my button seems to have focus so then if I click on that area the button works but otherwise it does not.
When I click within my botton's working area >handleEvent: anEvent> is called by
processMouseOver: anEvent>.
When my button does not work the method is not called because, I believe, the portion of my button that was clicked does not have focus. Note that when my button size is expanded it's position is also changed because other morphs have also expanded but this expansion does not seems to cause confusion as to where the button is because the working focus area remains in the same part of my button. But there appears to be confusion as to the size of my button and its focus area.
Debugging this is a pain. When I set a break point in
handleEvent: anEvent>
the emergency handler pops up. when I do a I get my stack with
handleEvent: anEvent> at the top of the stack.
But I have gathered little useful information by looking at this stack. The only solution I can think of is to discard by button (buttons) and reinstantiate them every time they need to be resized.
Is there something that I should be setting when I resize my button so that it's focus area is correct?
Is discarding my buttons and reinsantiating them the only solution?
Any help or insight appreciated.
Ralph Boland _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org