How to change Action bar for each Tab in Nativescript Angular - nativescript

I hav TabBar app using Nativescript Angular. I want to change the Action Bar buttons based on the selected tab.
I just follow this tutorial https://www.youtube.com/watch?v=7go3L70QfIQ
But, don't know how to use TabView.selectedIndexChangedEvent in Angular.
If anyone has done this, please share the piece of code.
Thanks

Use this example as a reference on how to use the selectedIndexChange event in Angular based application.
For example:
<TabView selectedIndex="0" (selectedIndexChange)="onIndexChanged($event)">
<!-- more code follows here -->
And then in the component file use the onIndexChanged callback
public onIndexChanged(args) {
let tabView = <TabView>args.object;
console.log("Selected index changed! New inxed: " + tabView.selectedIndex);
}

I solve the issue using rxjs/Observable notifications. Logic is post a notification when the tab changes happen. Based on the tab index, I can decide the action bar button tap event methods.
// send notify to child components
let message = {
"tabIndex" : this.tabIndex,
"tappedButton" : "someButton"
};
this.notifyService.send(JSON.stringify(message));

Related

MDC web components - Deactivating focus from textfield not working

I am trying to implement an autocomplete input by using mdc web components. I have a menu selected event listener, where I want to deactivate focus on a textfield. I have tried that by using MDCTextFieldFoundation deactivateFocus method:
const inputFoundation = new MDCTextFieldFoundation(
document.querySelector(".mdc-text-field")
);
menu.listen("MDCMenu:selected", e => {
console.log(inputFoundation);
input.value = e.detail.item.dataset.value;
inputFoundation.deactivateFocus();
});
But, that is not working. In the console, I can also see that input's property isFocused is false, when textfield is still focused. You can see the whole codesandbox here. What am I doing wrong here and what is the correct way of deactivating focus from a textfield?
From docs:
Deactivates the focus state of the Text Field. Normally called in response to the input blur event.
So deactivateFocus updates the state of the component, but it doesn't change focus.
You need to call blur yourself. For example like this:
document.activeElement.blur()

How to show a dialog in SAPUI5 triggerd by the controller and not a view event? (Push notification)

In a SAPUI5 controller of a master view I trigger a oModel.read() request to read some data (async). This read will be done each time the page will be reached during navigation.
onInit: function() {
var that = this;
this.getRouter().getRoute("PageName").attachMatched(this.onRouteMatched, this);
},
onRouteMatched : function(oEvent) {
...
oModel.read(....); // this will be done async
...
},
The app should be normal rendered (with normal binding).
The mentioned read will load some messages from the server and syncs it with a local model. Now in case of a new message a dialog should be shown.
Here is my problem: Where to place the dialog.open() call in the controller (what event?) so that the dialog will be shown?
Right now I tried with onAfterRendering and there it works for exactly the first call. For further calls I can't see any dialog. If I place the open dialog in the onRouteMatched I can see a short flickering.
So the problem is, that opening the dialog should be done after the rest of the application is rendered. But how to reach this?
Meanwhile I have a hacked solution.
In the onInit method of the controller I register to the onmousemove event. Each time the mouse will be moved I can check if there is some data to show.
this.getView().attachBrowserEvent("mousemove", function(oEvent) {
this.onCheckForMessages();
});
But better solutions are welcome.

How go from one UI to another UI on Image button click event in juce introjucer?

can you please tell me How go from one UI to another UI on Image button click event in juce introjucer?
Basically you have to:
1.- Parent component must inherit from ButtonListener, and you must implement the buttonclicked method
void WindowComponent::buttonClicked (Button* activeButton)
{
if (activeButton == &someButton)
{
gotoOtherPage();
}
}
2.- Your "UIs" i must suppose are components, if so just do something like:
component.setVisible(false),
otherComponent.setVisible(true),
Or perhaps stash them in a TabbedComponent, hide the tabs or overlap some buttons and then just do:
tabbedComponent.setCurrentTabIndex(someIndex);
That should get you going, in case you need help to draw a button just do something like:
addAndMakeVisible (&someButton);
someButton.setBounds(...);
someButton.addListener(this);
Check out the doxygen docs, they are quite helpful.

How to call the same function that the ToolBar editbutton does

So I have created a context box upon right click that has Add/Edit/Delete Rows. I also have a bunch of code launched before the Dialog is shown. My problem is that when I use the context menu it doesn't go through some of the code. I have tried to call on the functions directly but it doesn't format correctly.
I am mainly concerned with the edit button, here is the code I am using to bring up the edit Dialog
function editRow() {
var grid = jQuery("#<%= Jqgrid1.ClientID %>");
var rowKey = grid.getGridParam("selrow");
if (rowKey) {
// I have tried calling functions here and it still doesn't work
grid.editGridRow(rowKey, grid.editDialogOptions);
}
else {
alert("No rows are selected");
}
}
So if I use this to display the editform it isn't formatted correctly nor does it go through the functions all correctly.
I am using the ASP Webforms version of Jqgrid so I call the function by doing this
<cc1:JQGrid1 ID="Jqgrid1
//other attributes
ClientSideEvents-BeforeEditDialogShown="ChangeMonitor"
//Rest of code />
So this works just fine, and I'm trying to get the Edit button on the context menu to display correctly.
My thought was to use Jquery to trigger a click on the actual Edit button once someone used the context menu. I couldn't find an ID that would work however.
Is there an easy way to connect my context menu Edit button, with the actual Edit button in the toolbar?
Well I found a solution to my problem.
The id field of the button was edit_ct100_cpMainContent_Jqgrid1_top so I just triggered a click with this code.
$("td[id^=edit][id$=top]").trigger("click")
For some reason when I used the _ct100_cpMainContent_Jqgrid1 it wasn't working, but now it does. Hope this helps someone.

Vaadin how to change default validation functionality

I am using vaadin in a portlet environment where we have specific validation look & feel and behavior.
When input fields have invalid values,
their borders color becomes red.
All the error messages (as link) are shown above or below at common location.
Clicking on specific error results into cursor focus going to related field.
So how can i achieve this functionality and what i need to change & modify.
For your point #1, You need to create a theme. To do that, I suggest you to read the Book of Vaadin chapter 5 and 8.
Chapter 5 explain the ui component and css style associated with them.
Chapter 8 explain how to inherits a css theme.
For point #2, You have to add a layout to your page, and for each message youy will create a button and style it like a web link.
Button button = new Button("Your error message");
button.setStyle(BaseTheme.BUTTON_LINK);
errorLayout.addComponent(button);
For point #3, add listener to your button link, and when clicked, focus the component in error. So the previous code will now look like this
Button button = new Button("Your error message");
button.setStyle(BaseTheme.BUTTON_LINK);
button.addListener(new Button.ClickListener(){
public void buttonClick(ClickEvent event){
// Replace componentInError by the associated component of the link.
componentInError.focus();
}
}
errorLayout.addComponent(button);
Regards.
Éric

Resources