Change Label Text Alignment in App Inventor 2 code block - app-inventor

I would like to know wether we can change the Text Alignment of a label using the App Inventor 2's Code Block. I would like to make a button to select the text alignment position of a label or button.

You can't change the text alignment of a label programmatically in App Inventor
As workaround for example define 2 Labels, one having an alignment left and another having an alighment right and hide the second label. Then after button click copy the text of the label and display the other label instead, see screenshot.

Related

Ionic 6: How to custom ion-accordion icon place right after header label

I'm trying to implement the follow design:
I'm using ion-accordion, but property "toggle-icon-slot" provide only 2 options to put icon at the start right before header label or at the end.
Is there a way to place the icon right after header label but keep 'ion-accordion' width responsive, because I want 'change' button at right edge of screen.

WIN32: Is there a way to have the button icon (BM_SETIMAGE) on the right side of the text

Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
I want to just sent BM_SETIMAGE and whatever else would be needed so the graphic is to the right of the text.
Also, I noticed the image is so tight against the text that it doesn't look good. Is there a way to adjust the margin without having to use a blank space in the text?
Is there a way to have a button with text and graphic, with the graphic on the right side of the text, without having to owner-draw the button?
There are BS_LEFTTEXT and BS_RIGHTBUTTON styles available, but the documentation says they only apply to CheckBoxes and RadioButtons:
Constant
Description
BS_LEFTTEXT
Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.
BS_RIGHTBUTTON
Positions a radio button's circle or a check box's square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.
For a standard push button, there does not appear to be a way to control the position of the image other than through owner-drawing.
Is there a way to adjust the margin without having to use a blank space in the text?
Use BCM_SETTEXTMARGIN/Button_SetTextMargin():
Sets the margins for drawing text in a button control.

How to create consistent toolbar buttons with icons

Desired look
I wish to make a toolbar for my app that will contain some simple buttons, each with a single monochromatic icon. Here is an example of some toolbar buttons similar to I'm trying to achieve, from Mail's compose window:
Notice these buttons have a consistent size, inner padding, padding, and shading. This is a pretty consistent style across macOS, present in Mail, Safari, Finder, etc. This leads me to suspect there's a standardized UI component for creating such buttons.
If I use a segmented control, each button looks correct, with each icon being correctly padded:
Now I would like to add individual buttons that match the style.
Attempt 1
My first attempt was to add a "Push Button" (NSButton) to the toolbar:
This resulted in a wide button that's a bit too short, and not lined up with the segmented control:
Attempt 2
My second attempt was to use a segmented control, with only 1 segment.
This resulted in a button that's the right shape, size, etc., but it was off center relative to its label.
Naturally, I can manually adjust the button to match the goal, but I feel like I'm missing something. What's the proper way to create these standard buttons?
This is actually quite easy to do and you were close already.
You can use NSButton for that. Note that it has different styles (defined in NSButton.BezelStyle) to choose from. The default one is the one to use inside windows and modals. But for toolbars, to match the style of segmented controls and search bars, you can choose the style .texturedRounded.
You can also set the style via Interface Builder. Note that you have to select the button itself, not the toolbar item around it.
To get the correct size, you seem to set the icon within the toolbar item, not the button itself.
Here is my result:

XCode: Graphical button with invisible title

I have a bunch of buttons. They appears as an graphical image. If a user clicked on a button I can determine with
sender.titleLabel!.text!
which button the user pressed. But the title of the button appears in the view. I want only to show the image and give the button a invisible title. But I think that is not possible.
Me second solution is to create for each button an outlet. But I think with 30 buttons that is a very bad solution.
Option 1:
For the button text color property set opacity to 0. The text is there, but fully transparent.
Option 2:
You may use the tag value to identify a button so you do not have to rely on the button title. You can set the tag value in interface builder (Xcode) or in code. (The tag is an integer.)
I usually prefer option 2 as it is resilient to text changes over time (think of typos, translations for other languages etc.).

How to show the picture box in front of textbox, combo box inside the Frame?

Using VB 6
Am using Frame, Inside that frame am using textbox, combo box, labels.
When I am running the project it will show like "processing".
So I used the picuture box also inside that frame. But Picture box is not showing in the front of textbox, combobox, labels.
I tried, but it is showing only the picture layout, it is not showing the label “processing”
How to set a property for this condition.
Exactly i need, while executing the program it will show like processing then it will display a output.
Need VB 6 Help
A label component does not have a window handle -- hWnd, but instead is drawn right on its parent (in this case, the frame component it sounds like).
A combobox, a textbox, and a picturebox all have a window handle (hWnd), so can have a zOrder and appear behind/in front of other components.
I believe the answer to your question is to place the label component inside a picturebox, and then set the zOrder of the picturebox as needed.
It sounds like your label is underneath one of the other controls (your question isn't particular clear) - if that is the case, you need to play with the ZOrder property of your controls to be able to decide which control gets to be on top (i.e. to be displayed). This link gives you an example of how to use this property.

Resources