So, I am working on this school project where I created multiple buttons with text loaded from my database. These buttons are created everytime by listing a new button with another piece of text within it. I need my other function to be called while one of those buttons is being pressed.
The simple button function:
public Button addOptionToSidebar(String Text)
{
optionSize++;
Button optionButton = new Button();
optionButton.setAlignment(Pos.CENTER);
optionButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
optionButton.setText(Text);
optionButton.setStyle("-fx-background-color: #fff; -fx-cursor: hand;");
//Toevoegen aan sidebar
CollectieSidebar.addRow(optionSize, optionButton);
return optionButton;
}
Everytime a button is being created, the function above is being called.
I feel extremely dumb for asking this. This issue is fixed of course by creating an onAction statement within the creation of each button.
Related
I have a page with a collection view and a search bar that filters its contents.
I want the filtering to happen as the user types in the search bar, so I bind the TextChanged event of the SearchBar to a command in the view model, like so
var eventToCommandBehavior = new EventToCommandBehavior()
{
EventName = nameof(searchBar.TextChanged),
};
eventToCommandBehavior.SetBinding(EventToCommandBehavior.CommandProperty, nameof(MyViewModel.StartOrResetSearchTimerCommand));
searchBar.Behaviors.Add(eventToCommandBehavior);
In the view model:
public ICommand StartOrResetSearchTimerCommand => new Command(() =>
{
StartOrResetSearchTimer();
});
private void StartOrResetSearchTimer()
{
if (!timerStarted)
{
searchTimer = new Timer(_ => PerformSearch(), null, searchTimeout, searchTimeout);
timerStarted = true;
}
else
ResetTimer();
}
private void PerformSearch()
{
//my code
OnPropertyChanged(collectionViewItemsSourceBinding);
}
The StartOrResetSearchTimerCommand filters the ItemsSource binding, and calls OnPropertyChanged(itemsSourceBinding) to update the UI.
On Android and UWP everything works as expected. However on iOS, when OnPropertyChanged is called, the focus moves out of the search bar, resulting to the soft keyboard being closed after each keyboard input.
Has anyone else encountered this? Any suggestions?
I have already tried not using this approach, and only filter the ItemsSource when the search button is pressed, which works, when there is something to search for (ie, there is some input in the search bar)
When the search bar text is empty (ie after Backspace) then the search button is greyed out.
Update
For now, I am using this workaround:
Perfom the search only when the search button is pressed, and on TextChanged, check if the text is empty and reset the ItemsSourceworka
TextChanged is called anytime the text in the query box is changed. You can use this event to update your ItemsSource when the Text of the searchbar changes. You can refer to this part of the official example. First, given your ItemsSource, when you enter text in the searchbar, call the OnTextChanged event to update your ItemsSource, so that the real-time search keyboard will not lose focus.
I am trying to disable double clicking a Help label which is an anchor to open the Help window.
<p:a id="helpClick" onClick="help()">
<label value="Help" style="color:#FFFFFF;" />
</p:a>
When onClick() event is triggered once, either by Mouse click or Tapping the touchpad once, the help() method is being invoked.
void help() {
flag = true;
this.helpClick.setDisabled(true);
Window popupWindow = null;
popupWindow = (Window) Executions.createComponents("/zul/mainHelp.zul",
null, null);
this.popupWindow.setClosable(true);
popupWindow.addEventListener("onClose", new EventListener() {
void onEvent(Event event) throws Exception {
this.helpClick.setDisabled(false);
}
});
}
is the code which i added to handle the anchor tag with the id helpClick.
This is working perfectly fine when i use mouse clicks. For the first click, the window gets opened and simultaneously the Label is not taking any more click events.
When i try the same with mouse tap(using the touchpad), two single clicks are being triggered.
I have used onClick() to capture the event.
I am trying to disable the Label once it is clicked and the window is opened. Only after the window gets closed, i am enabling the label.
This is working totally fine when i use mouse clicks but not when i use tap.
With tapping, the label is taking multiple clicks which isnt the case with Mouse Click.
Without seeing code it's difficult to provide advice but maybe you can capture the onDoubleClick event and ignore it or forward it to the to the same listener as your onClick event.
... forward="onClick=onHelpClick,onDoubleClick=onHelpClick" ...
After question edit:
It sounds like a bug if you can double click a disabled component. One thing you could try is set your link to autodisable <p:a id="helpClick" onClick="help()" autodisable="self"> as per A component documentation
I'm using DX 15.1, and I'm trying to create a new tab from a child form.
So, basically, I have a parent form called "pForm", and a child form called "cForm".
I'm using DocumentManager module and switched it to TabbedView mode.
When I'm trying to create a new tab from pForm, it's totally fine.
the problem is, when I'm can't create a new tab from cForm into pForm's TabbedView.
How do I achieve this?
Thanks, mate :)
UPDATE :
#DmitryG, thanks for your response.
I've attached a screenshot below.
The MDI-Parent is the RGP page with a settings header. and the MDI-Child is the Class Attendance form (popped-up window, triggered by a button inside the RGP form).
Can you give a solution, how to make the Class Attendance Form (mdi-child) became a new Tab beside RGP tab when it's triggered by a button within mdi-parent? Not as a popped-up window.
thanks!
When the DocumentManager works in MDI Mode you can just work with mdi parent and child forms. So, I believe, you code for adding a new mdi-child into mdi-parent form can looks like this:
static void AddMdiChildFromMdiParent(Form mdiParent) {
Form child = new Form();
child.MdiParent = mdiParent;
child.Show();
}
Within the mdi-parent form you can call this code like this:
AddMdiChildFromMdiParent(this);
To add a new mdi-child from an existing mdi-child you can reuse the code above as follows:
static void AddMdiChildFromMdiChild(Form child) {
AddMdiChildFromMdiParent(child.MdiParent);
}
I have two layouts in JavaFX app. The first one contains table view whereas the second one is a simple dialog to input data. The problem is that I want to refresh data after closing the dialog. Now I have a button on the first layout which refreshes data:
data.removeAll(data);
loadDataToTable();
But I don't want to invoke methods shown above with the button but automatically right after closing the dialog. I don't know how to make this, let's say, connection between those controllers.
thanks in advance
The new Dialog, if I am not wrong must be a new Stage ! Let us consider the new Stage to be modifyStage. We can call the onSetCloseRequest of the new Stage and put your code in it.
modifyStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
#Override
public void handle(WindowEvent paramT) {
data.removeAll(data);
loadDataToTable();
}
});
I have created an Accordion dynamically and added AccordionPanes through backend with respective controls and data click here to view my problem and how I solved it. I have added a link button in each AccordionPane but now I want to add a click event so that I can access data in that specific pane and I need to use functions to populate data.
I create my controls in the page_init event.
How can I go about doing this?
I have come across a solution that is almost the same as what I want to do.
One way to achieve this is by adding the event handlers with Javascript Like this:
function pageLoad()
{
var accordionControl = $find('Accordion1_AccordionExtender');
accordionControl.add_selectedIndexChanging(PaneChanging);
accordionControl.add_selectedIndexChanged(PaneChanged);
}
function PaneChanged(sender, args)
{
alert('In Changed handler.');
}
function PaneChanging(sender, args)
{
alert('In Changing hanlder.');
}
A similar question has been posted here
The specific control you would be looking for is:
$addHandler(header, "click", acc._headerClickHandler);