Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button with icon and text that matches parent extent #43

Open
tinchodias opened this issue Jun 1, 2023 · 4 comments
Open

Button with icon and text that matches parent extent #43

tinchodias opened this issue Jun 1, 2023 · 4 comments

Comments

@tinchodias
Copy link
Collaborator

How do you recommend to build a button like this in morphic?

Screenshot 2023-06-01 at 13 42 31

I started with an example in ToSandbox, with a ToButton, but I think I should use ToGeneralButton. Am I right?

but := ToButton new.
but label: 
	((ToLabel text: 'Make something cool happen')
		matchParent;
		alignCenterLeft;
		yourself).
but icon: 
	((ToImage inner: (self iconNamed: #remove))
		matchParent;
		layoutDo: [ :l |
			l verticalAlignment: BlElementAlignment vertical center.
			l horizontalAlignment: BlElementAlignment horizontal end ];
	yourself).
but matchParent.

space := OBlSpace new.
space root addChild: but.
space show 
Screenshot 2023-06-01 at 13 39 54
@plantec
Copy link
Collaborator

plantec commented Jun 1, 2023

Yes, a ToButton is more for vFitContent.
Have a look at this example:

example_toBasicButton2

| but lab |
lab := ToLabel new text:
	       (('Button' asRopedText)
		        fontSize: 40;
		        yourself).
but := ToGeneralButton new dresser: ToGeneralButtonDresser new.
but matchParent.
but addChild: lab.
but layout alignCenter.
but whenClickedDo: [ self inform: 'clicked' ].
but openInOBlSpace 

@plantec
Copy link
Collaborator

plantec commented Jun 1, 2023

but it should be possible with a ToButton. I will have a look and push a fixe if it is an issue

@plantec
Copy link
Collaborator

plantec commented Jun 1, 2023

with a ToGeneralButton:

example_toBasicButton4

| but lab ico pane |
pane := ToPane new.
pane fitContent.
pane layout alignCenter.
lab := ToLabel new text: 'Button'.
ico := ToImage inner: (self iconNamed: #remove).
pane addChildren: { lab. ico }.
but := ToGeneralButton new dresser: ToGeneralButtonDresser new.
but matchParent.
but addChild: pane.
but layout alignCenter.
but whenClickedDo: [ self inform: 'clicked' ].
but openInOBlSpace 

@tinchodias
Copy link
Collaborator Author

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants