Charm 4.0.1 DatePicker unwanted white frame - gluon

After the update to Charm 4.0.1 there is an unwanted white frame around the DatePicker:
It seems to be caused by the padding of the VBox which contains the DatePicker.content.
Setting css via stylesheet, didn't change the padding, so my only solution so far has been the following:
public class DatePickerFrameless extends DatePicker {
public DatePickerFrameless(LocalDate date) {
super(date);
rootNode.visibleProperty().addListener((obsValue, b, b1) -> {
if (b1) {
VBox container = (VBox) rootNode.lookup(".container");
container.setStyle("-fx-padding:0;");
}
} );
}
}
Is there a more convenient way to get rid of the frame?
EDIT:
Setting css via stylesheet works:
.dialog > .container {
-fx-padding: 0;
}

Related

How to change the default background color when select a row?

I used kendo ui, when I selected a row; the default background color is pink.
The current code doesn't include any information of when clicking a row then setting the background color.
My question is how can I change it by my requirement? Let's say I want to blue color when I select the row.
export class AppComponent {
public gridData: any[] = products;
public checkboxOnly = false;
public mode = 'multiple';
public selectableSettings: SelectableSettings;
constructor() {
this.setSelectableSettings();
}
public setSelectableSettings(): void {
this.selectableSettings = {
checkboxOnly: this.checkboxOnly,
mode: this.mode
};
}
}
StackBlize
The color is set by the following CSS rule:
.k-grid td.k-state-selected, .k-grid tr.k-state-selected > td {
background-color: rgba(255,99,88,0.25);
}
You can add your own CSS to override it.
You can also override SASS variables to change some colors in the entire application, in this case $selected-bg or $grid-selected-bg. More info here: https://www.telerik.com/kendo-angular-ui/components/styling/theme-default/customization/

SPFx: How to re-render my WebPart on section layout change

I'm trying to make my WebPart responsive to the column width in my section layout.
I get the width of the bounding rectangle by calling
const width: number = this.domElement.getBoundingClientRect().width;
My render-function looks like this:
public render(): void {
const width: number = this.domElement.getBoundingClientRect().width;
this.domElement.innerHTML = `<div>${width}</div>`;
}
When I insert my WebPart into the SharePoint workbench, the number 736 is shown.
However, if I change the layout of the section from one column to something else, the number doesn't change.
What do I need to do to trigger the render function as soon as the layout (and therefor the width) changes?
To do that you can create an event listener and in your function set the state to re-render your webpart:
private handleWindowSizeChange() {
this.setState({
size: window.innerWidth
});
}
public componentDidMount() {
window.addEventListener('resize', this.handleWindowSizeChange.bind(this));
}
public componentWillUnmount() {
window.removeEventListener('resize', this.handleWindowSizeChange.bind(this));
}
I have used the ResizeObserver api to listen for the layout change in the layout.
The only problem is that it is not supported by IE, Edge, and Safari.
public componentDidMount() {
if(window.ResizeObserver) {
this.resizeObserver = new ResizeObserver(this.handleResize);
this.resizeObserver.observe(this.domElement)
}
}
public componentWillUnmount() {
if(window.ResizeObserver) {
this.resizeObserver.disconnect()
}
}

Nativescript scroll to bottom of ScrollView programmatically

In my Nativescript Angular application, I have a TextView within a ScrollView, defined as such:
<ScrollView orientation="vertical" height="70%" width="100%" style="margin-bottom: 1%; background-color:white" (loaded)="onScrollerLoaded($event)">
<TextView
id="terminal" [text]="terminalText" editable="false"
style="color: whitesmoke; background-color: black; font-size: 8%; font-family: monospace" height="100%"
(tap)="onTap($event)" (loaded)="onTerminalLoaded($event)">
</TextView>
</ScrollView>
The purpose of this element is to act as a terminal, and is rapidly printing incoming messages from a bluetooth device.
Currently, the ScrollView is scrolling back to the top whenever I add some text to the terminalText variable, to which the TextView is bound. I would like to be able to keep the ScrollView at the bottom of the TextView.
A few notes:
I am adding text to the terminalText variable within my associated component class through this method:
public appendToTerminal(appendStr){
this.terminalText += appendStr;
}
I have tried implementing the following code that would execute once the ScrollView loads:
private scrollIntervalId;
onScrollerLoaded(data: EventData){
if(!this.scrollIntervalId){
this.scrollIntervalId = setInterval(()=>{
this.ngZone.run(() =>
(data.object as any).scrollToVerticalOffset((data.object as any).scrollableHeight, false)
)
}, 10);
}
}
(This attempt is based on an explanation given here
I have only tried this on an Android device, as I do not have access to an Apple device.
you are setting TextView to fixed height 100% which is will be same as ScrollView that is why scrollableHeight will always be 0. you should use minHeight="100%".
then you can scroll programmatically to the end when you are appending text to terminal text this.terminalText += appendStr.
like this
public appendToTerminal(appendStr){
this.terminalText += appendStr;
setTimeout(()=>{
scrollView.scrollToVerticalOffset(scrollView.scrollableHeight, false);
},150);
}
this will append the text then get the scrollableHeight and then will scroll to it.
here is working playground demo:https://play.nativescript.org/?template=play-ng&id=Rs0xnP&v=16
The function below can only be used in the Angular ngDoCheck() or ngAfterContentChecked() lifecycle:
// See https://angular.io/guide/lifecycle-hooks
function goDownScrollView(scrollView: object, animate: boolean = true): boolean {
let neScrollView: ScrollView = <ScrollView>getNativeElement(scrollView),
scrollableHeight: number = neScrollView.scrollableHeight;
console.log("neScrollView:", neScrollView);
console.log("neScrollView scrollableHeight:", scrollableHeight);
if (scrollableHeight > 0) {
neScrollView.scrollToVerticalOffset(scrollableHeight, animate);
return true;
} else {
return false;
}
}
An helper to always get the native element:
function getNativeElement(object: object): object {
return (object.hasOwnProperty("nativeElement")) ? object['nativeElement'] : object;
}
The scrollable height may be zero at the first pass of the lifecycle (for example, if you add elements to your ScrollView with an HTTP request). That's why you have to test the current content with new before scroll:
// See https://angular.io/api/core/ViewChild
#ViewChild("content") private _pageContent: ElementRef<ScrollView>;
public currentContent: object;
private _previousContent: object;
...
ngAfterContentChecked(): void {
if (this.currentContent != this._previousContent) {
let isScrollDown: boolean = goDownScrollView(this._pageContent);
if (isScrollDown) {
this._previousContent = this.currentContent;
}
}
}

Add Border Styling to VBox in TornadoFX

In a view for my TornadoFX app, I have a borderpane that has a VBox on the left and right sides of the view (nothing in the center). As of right now, each VBox has the same background color so they kinda blend together. I would like to show some sort of separation between the two VBoxes (i.e. either one VBox has a slightly darker tint, a border color, or both). Would anyone happen to know how to add border styling to a vbox? Or add a background color?
For clarification, I'm looking for a way to do this inside the body of my View class definition so I'm not using a CSS or FXML for styling.
The best way to do this is to create a type safe style sheet where you define a class for each vbox and assign those classes to the vbox. Here is a complete app with the stylesheet, app definition and main view:
class MyApp : App(MainView::class, MyStyles::class)
class MyStyles : Stylesheet() {
companion object {
val leftBox by cssclass()
val rightBox by cssclass()
}
init {
leftBox {
backgroundColor += c("#cecece")
borderColor += box(c("#a1a1a1"))
minWidth = 200.px
}
rightBox {
backgroundColor += c("#fefefe")
borderColor += box(c("#222222"))
minWidth = 200.px
}
}
}
class MainView : View("My View") {
override val root = borderpane {
setPrefSize(800.0, 600.0)
left {
vbox {
addClass(MyStyles.leftBox)
}
}
right {
vbox {
addClass(MyStyles.rightBox)
}
}
}
}
If you're allergic to stylesheets you could set these properties inline or use an inline stylesheet as well:
class MainView : View("My View") {
override val root = borderpane {
setPrefSize(800.0, 600.0)
left {
vbox {
style {
backgroundColor += c("#cecece")
borderColor += box(c("#a1a1a1"))
minWidth = 200.px
}
}
}
right {
vbox {
style {
backgroundColor += c("#fefefe")
borderColor += box(c("#222222"))
minWidth = 200.px
}
}
}
}
}
Lastly, you can configure the corresponding properties of the nodes instead of applying styles. I won't give an example of that as you really shouldn't do it :)

Use parameters for variable animation

I'd like to animate my Score-GUI text counting up to a variable value but there are two things in my way:
1: How can I animate to a variable instead of a fixed value?
2: Why can't I add own properties (like int) to my script and animate them?
For #2 I created a property in my script. Yet the editor won't show it in the AddProperty-dialog (as shown below):
public int currentScore = 0;
public int score {
get { return currentScore; }
set { this.currentScore += value; }
}
EDIT: The animator is set up in the most basic way:
Since you only have 1 Animation. An Animator is irrelevant to the solution. This is tested and working. Now you need to make the Animation a Legacy type to get this working because we are not going to use the Animator.
Click the Animation on the Project -> look at the upper right section of the Inspector view, there is a little button there which will drop down a selection. "Debug" then Check the Legacy.
Set your Animation to whatever you want. I force the WrapMode in the script to be wrap mode once. So it will only play once.
Now in the Animation Component make sure you select the Animation that you want by default or it wont work. Cause we only use anim.Play(); Without parameters meaning, run the default animation that is set.
I created a Text UI and added an Animation that alpha is 0 from the start and at the end point making it 1. You have to do that on your own.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyScore : MonoBehaviour {
// Use this for initialization
public int currentScore = 0;
public GameObject Myscore; // Drag the GameObject that has the Animation for your score.
public Text myScoreText; //Drag in the Inspector the Text object to reference
public Animation anim;
public int score
{
get { return currentScore; }
set { this.currentScore += value; }
}
void Start()
{
anim = Myscore.GetComponent<Animation>(); // Reference the Animation Component.
anim.wrapMode = WrapMode.Once; // Legacy animation Set to play once
AddScore();
}
public void AddScore()
{
score += 10;
myScoreText.text = score.ToString();
anim.Play();
Debug.Log("Current Score is "+ score);
Invoke("AddScore", 2);
}
}
Good luck.

Resources