MudBlazor: how to display notification in Bottom-Right of window? - mudblazor

I have created an app using MudBlazor template.
All is ok, I use MudBlazor Snackbar and in MainLayout I use
and button on it.
On click I call a function
ShowNotification("BottomRight")
private void ShowNotification(string position)
{
Snackbar.Clear();
Snackbar.Configuration.PositionClass = position;
Snackbar.Add(message, Severity.Normal);
}
I'd like to show notifications in the Bottom-Right of the Browser window but it displayed in left top corner because it is MudAppBar.
How to display notification in the Bottm-right of browser window?

You should not be using "BottomRight" but Defaults.Classes.Position.BottomRight instead:
#inject ISnackbar Snackbar
<MudButton
OnClick="#this.ShowMessage"
Color="Color.Success">
Show message
</MudButton>
#code {
void ShowMessage()
{
this.Snackbar.Clear();
this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
this.Snackbar.Add("Wazzup?", Severity.Normal);
}
}
Demo: https://try.mudblazor.com/snippet/wumnYmbNHjwLplPt

Related

Print button on webview is not working

I have a webpage that has a "Print" button and works normally when using Any Browser on mobile phone.
But when using the webview, is not working. Its like not firing.
For java
private void createWebPrintJob(WebView webView) {
PrintManager printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
String jobName = getString(R.string.app_name) + " Print Test";
printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
}
//perform click pdf creation operation on click of print button click
// Use this on main activity class tag
public void printPDF(View view) { createWebPrintJob(myWebView); }
For Xml Create Button
android:onClick="printPDF"

How to higlight button color when hover the mouse after a click?

I'm doing a piano application thought to be played on mobile devices (Android). All the piano keys are UI buttons that have the "property" pressed color to a grey one in order to properly indicate when a piano key is emiting sound.
My current problem is that when I first click on a key and after that I drag the mouse over the following keys, only the first one that I clicked is getting the change of color (the idea is that the change of color duration finishes when other key starts sound and then the new key where I pass the mouse-finger gets the grey color).
I also tryied setting the higlighted color property to the same color as the pressed color with the Navigation parameter to none (if it's set to automatic it happens some kind of bug that the color is getting "stuck" until I make sound another key), but the result it's still the same.
EDIT:
I update the issue with some progress thath I made:
I'm trying to change the pressed color with a script thanks to the events Pointer enter and exit (both events are placed on a Event trigger in every button).
Code:
public class ChangeKeyColor : MonoBehaviour{
public Button button;
void Start()
{
}
void Update()
{
}
public void EnterKey () {
Debug.Log("Enter the key");
ColorBlock colors = button.colors;
colors.normalColor = new Color(179, 179, 179, 255);
//colors.highlightedColor = new Color32(179, 179, 179, 255);
button.colors = colors;
}
public void ExitKey()
{
Debug.Log("Exits the key");
ColorBlock colors = button.colors;
colors.normalColor = Color.white;
//colors.highlightedColor = new Color32(255, 255, 255, 255);
//colors.pressedColor = Color.white;
button.colors = colors;
}
}
The only improvement that I obtained is that now when I'm dragging the mouse (maintaning it) the first button returns to white color, but I think that this is happening because now I only setted to gray color the pressed color option...
Does anyone know why the pressed color change that I'm making in the script isn't happening? When I drag the mouse to another key isn't considered as a pressed button?
Regards!
I'm not sure if you are still looking for the answer, but I finally had some time to try it myself.
What I did is changing color and debug-logging transform's name instead of playing sound.
My code for Images/Buttons (attached to each Image, I didn't use Button components):
using UnityEngine;
using UnityEngine.UI;
public class ChangeColor : MonoBehaviour {
public Color activeColor, notActiveColor;
private Image thisImage;
void Awake () {
thisImage = GetComponent<Image>();
}
public void OnPointerClick()
{
Activate();
}
public void OnPointerEnterAndDown()
{
if (Input.GetKey(KeyCode.Mouse0))
{
Activate();
}
}
public void OnPointerExit()
{
thisImage.color = notActiveColor;
}
private void Activate()
{
Debug.Log(transform.name);
thisImage.color = activeColor;
}
}
EventTrigger settings:
And this is what it looks like in the end:
(This should be a comment, but it's a little long, so reply me and I'll update the answer)
I don't know why are you having this problem, I do the simple test creating 2 UI Buttons and setting the highlighted color to red, and the pressed to blue.
By default (there's no script attached to anything) the behaviour is the follow:
1.If I press (and mantain) the click on a button, that button is blue, when I release the "pression", the button keeps red.
2.While this first button is red, if I drag the mouse over the second button, this will be also red.
3.If now I press on the second button, the first behaviour applies to the second button, and the first one will be white again.
This is the following behaviour that you want, according to what I understood.
So, if this is not the desired behaviour, tell us more about what you want.

Navigation back between two fragment xamarin android

MainActivity
ActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu_white_24dp);
ActionBar.SetDisplayHomeAsUpEnabled (true);
drawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
navigationView = FindViewById<NavigationView> (Resource.Id.nav_view);
Event click on navigatonView
CreateFragments();
LoadInditialFragment ();
navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
Onefragment
Twofragment
Navigation back from second Fragment to first fragment(navigation back on toolbar).??? MainActivity I have a button menu on toolbar.
I want to replace menu icon into back icon when It is standing at second fragment.
Download back arrow and save as navBack.png
Then in SwitchFragment method where we navigate between fragments
switch (FragmentId) {
case Resource.Id.nav_home:
ActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu_white_24dp);
transaction.Show (homeFragment);
transaction.Commit ();
break;
case Resource.Id.nav_genre:
ActionBar.SetHomeAsUpIndicator (Resource.Drawable.navBack);
transaction.Show (genresFragment);
transaction.Commit ();
break;
}
In Your MainActivity do this in OnCreate:
SupportFragmentManager.BackStackChanged += HandleBackstackChanged;
Implement the HandleBackstackChanged method like this
private void HandleBackstackChanged(object sender, EventArgs e)
{
ActionBar.SetDisplayHomeAsUpEnabled (SupportFragmentManager.BackStackEntryCount > 0);
}
What this will do is toggle between the Menu button and the Back button based on the BackStack count of the FragmentManager.
NOTE:
I am assuming you are using the Support library for backwards compatibility of Fragments. If you aren't using the support library, just use FragmentManger instead of SupportFragmentManager.

Show image in popup Vaadin

I use Vaadin 7. I want to display a full sized image in a popup. The popup does not contain any close button nor resize. Just an image that takes full size in a popup. Does anyone done that before ? Thanks.
Use standard PopupView with Content constructor.
PopupView c = new PopupView(new Content() {
#Override
public Component getPopupComponent() {
return new Image("caption", resource); //use any resource
}
#Override
public String getMinimizedValueAsHTML() {
return "displayedstring";
}
});
What do you mean by popup that does not contain any close or resize button?
You can use Vaadin's Window and disable the Close and Resize mechanism.
https://vaadin.com/book/vaadin7/-/page/layout.sub-window.html

Sticky button in GWT

can i create a button in gwt that onClick stays pressed and if it looks pressed onClick releases it?
and the button has a different styles in each state?
any idea?
That sounds like a ToggleButton.
This is a pretty basic approach that should give you the toggle that you want. Basically the first click will put a 'clicked style' that you've created that will give the thing the look you want for when it looks pressed. Clicking it a second time will revert back to your normal button style so it will look not pressed again.
final Button button = new Button();
button.setStyleName("NormalButtonStyle");
button.addClickHandler( new ClickHandler() {
private boolean clickedStyle = false;
public void onClick( final ClickEvent clickEvent ){
clickedStyle = !clickedStyle;
if( clickedStyle ){
button.setStyleName("ClickedButtonStyle");
}
else {
button.setStyleName("NormalButtonStyle");
}
}
});

Resources