I have a CButton object.
I added a bitmap file to the resource editor.
I do the following:
CButton m_btnClose; (in header file)
if (GetDlgItem(IDC_BUTTON_CLOSE))
{
HBITMAP hBMP = LoadBitmapW(AfxGetResourceHandle(), MAKEINTRESOURCE(IDC_BITMAP_CLOSE));
m_btnClose.ModifyStyle(0, BS_BITMAP);
m_btnClose.SetBitmap(hBMP);
}
The bitmap is actually loaded and applied to the button, but you can clearly see the regular button background behind it. Ignore the fact the button background is not the same color as the surrounding area.
Related
As soon as I create a new Button in JavaFX and set the background transparent with: myButton.setBackground(Background.EMPTY); or myButton.setStyle("-fx-background-color: transparent;"),
the hitbox will only consist of the text in the button when catching the ActionEvent via :
myButton.setOnAction(newjavafx.event.EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
//handle UI input
}
});
So I have to aim on a letter and click it, which is annoying, especially when having changing text and/ or small text.
How can I keep my hitbox the same while having a transparent background?
Use
myButton.setPickOnBounds(true);
which means that the layout bounds of the button will be used to determine mouse hits on it, rather than its set of non-transparent pixels.
I'd like an option with the TinyMCE color picker to choose transparent as the color so a character (a "bullet") will still be there and take up space but will not be visible if it's color is transparent.
There's an "X" box option that says "No color" but this seems to make the color black, not transparent.
Does anyone know how to add a transparent color option to this color picker, or even make the "X" box implement transparent instead of black?
Thanks for any ideas.
I believe I was able to do that, I did some quick tests and it appears to be working fine.
I got the latest version of TinyMCE (4.1.10_dev) to access the textcolor plugin's non minified javascript there's this instruction:
if (value == 'transparent') {
resetColor();
} else {
selectColor(value);
}
What happens here? When you choose a color it runs the selectColor, which wraps the selected text in a span with the selected color. However, when you select the no color it removes this color span (that's why it goes back to black which is the default color) instead of setting it to transparent.
So if you do this:
//if (value == 'transparent') {
// resetColor();
//} else {
selectColor(value);
//}
Instead of removing the span it will change it to 'transparent' instead.
One important thing is that tinyMCE gets the plugin scripts automatically, so it only works with the minified versions, so after you do these changes you'll have to minify the script to the plugin.min.js and put it on the textcolro plugin's folder overwriting the one there.
I hope it helps.
The × button in the colorpicker removes any custom colours, it does not add a zero-opacity colour.
As you can see when looking at the source code or trying the full example there is no support for rgba() or opacity in the included colorpicker plugin. Only rgb() and hex unfortunately.
You may need to create your own small plugin to add the ability. There are a number of alternatives, for example:
Create a CSS class which you can add to elements in the editor. Then do your colour magic in your own CSS file.
Create a new button in the toolbar which makes the element transparent.
I would personally go with option two, something like this:
tinymce.init({
selector: 'textarea',
plugins: 'nocolour',
toolbar: 'nocolour',
external_plugins: {
"nocolour": "url_to_your/nocolour.js"
}
});
And nocolour.js:
tinymce.PluginManager.add('nocolour', function(editor, url) {
// Add a button that opens a window
editor.addButton('nocolour', {
text: 'Remove Colour',
icon: false,
onclick: function() {
editor.undoManager.transact(function() {
editor.focus();
// Here is where you add code to remove the colour
editor.nodeChanged();
});
}
});
});
Rafael's solution worked for me. I just wanted to document it a bit more and show what it looks like for TinyMCE 4.1.7.
When you click the "X" in the textcolor grid the "value" variable gets "transparent," rather than a hex value from the colorMap.
The relevant code in the textcolor plugin is:
value = e.target.getAttribute('data-mce-color'); // the hex color from the colorMap square that was clicked. "transparent" if X was clicked
if (value) {
if (this.lastId) {
document.getElementById(this.lastId).setAttribute('aria-selected', false);
}
e.target.setAttribute('aria-selected', true);
this.lastId = e.target.id;
// if (value == 'transparent') { // occurs if you select the "X" square
// removeFormat(buttonCtrl.settings.format);
// buttonCtrl.hidePanel();
// return;
// }
selectColor(value);
The five lines I've commented out remove formatting for the selected text, leaving it black, which doesn't seem useful. If you wanted the text black you could select the black square in the colorMap. Falling through to selectColor(value) with value = "transparent" sets transparent as the color.
In Flex, when you use PopUpManager for popup windows, there is a background rectangle appearing over the application and behind the popup window itself. What I need is to override that default overlay rectangle with the custom one (in order to round the corners, apply gradient fill, etc).
How can this be achieved?
You can only change transparency, color and blur with css. See example:
global {
modalTransparency: 0.7;
modalTransparencyBlur: 0;
modalTransparencyColor: "0x000000";
}
Second way (if you want own design with round the corners, apply gradient fill, etc)
Create custom popup window (like TitleWindow) and when popup created or closed, dispatch from window custom event like:
dispatchEvent(new Event('addPopup', true));
In main application listen event:
systemManager.addEventListener("addPopup", onAddHandler, false, 0, true);
And then you can display own layer with custom design.
protected function onAddHandler(event:Event):void
{
// show custom background layer
}
How can I make an image button with transparent background?
The default background is grey color, I created the button with empty text and setIcon, something like this:
backButton = new Button(); //"Back");
backButton.setIcon(backIcon);
iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer).
setStyles(make(VALIGN.top, HALIGN.right)).
setBounds(0, 0, width, height).
add(backButton);
But could not figure out how to make the button to be transparent from the API / source code.
Any help / hint greatly appreciated.
You want to use Style.BACKGROUND.
If you want all buttons in your entire UI to have a blank background, then configure your root stylesheet like so:
Stylesheet ROOT = SimpleStyles.newSheetBuilder().
add(Button.class, Styles.none().
add(Style.BACKGROUND.is(new NullBackground())).
addSelected(Style.BACKGROUND.is(new NullBackground()))).
create();
Root root = iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer).etc().
If you just want a particular button to have a blank background,
configure it on the button:
Styles blankBg = Styles.none().
add(Style.BACKGROUND.is(new NullBackground()))
addSelected(Style.BACKGROUND.is(new NullBackground());
Button backButton = new Button().addStyles(blankBg).setIcon(backIcon);
Note also that SimpleStyles defines the backgrounds for buttons. If you start with a completely blank stylesheet, you can omit background definitions for your buttons and they will be blank.
The examples I've seen seem to show how to change the color that shows when the user actually hovers over the textinput field.
However when the validation fails, a generic textInput border qill have a red line over it. My CSS file uses a border skin for the textInput, so I can't see this line.
I was hoping there was a way to highlight the text box when it failed validation, or re-enable the red line feature. I don't want to get rid of my CSS cos it'll totally blow my color-scheme, but any tweak allowing the error line to show would be much appreciated.
This is the CSS:
TextInput, TextArea
{
border-skin: Embed(source='/../assets/images/input_bg.png', scaleGridLeft=8, scaleGridRight=20, scaleGridTop=8,scaleGridBottom=9);
padding-top:2;
padding-left:2;
font-size:11;
}
anything that extends UIComponent (both TextInput and TextArea do) has a style called errorColor. It defaults to red. You can change this to whatever you want.
Additionally, if you've got an image that you are using as a border, you should probably remove the pixels from the middle so that it is an actual border instead of an overlay.
The only way I've managed to find, is that Validator will change the component's borderColor style. I don't think it can be achieved using an image- you'll have to embed the image in a basic GraphicRectangularBorder subclass or similar. You can then add this to your skin class:
override public function styleChanged(styleProp:String):void
{
super.styleChanged(styleProp);
if (styleProp == "borderColor")
{
if (getStyle("borderColor") == getStyle("errorColor"))
{
// show error outline
}
else
{
// hide error outline
}
}
}