I've been using this book as reference to creating my Blackberry application. So far I have a list of items and when I select one I get the side menu but next to my list item:
Just looking through my methods, I'm not sure which one causes this as I can remove the custom item (GetValue) from the Menu and it will still appear here when I select the list item!
I guess my question is, how can I stop this menu appearing and have a method fire instead? I can provide code if necessary but I don't know where to start with this one!
Thanks
Can you show your code when invoking the method.
When I override the navigationClick method of the ListField class like in the code below it works properly. (no menu pops)
protected boolean navigationClick(int status, int time){
return true;
}
#ing0
You can override default menu by using OnMenu() method
public boolean onMenu(int i)
{
return false;
}
Related
On Android, TalkBack announces "Double tap to activate, double tap and hold to long press".
How can I remove all these default actions and just have it say nothing?
While ignoring whether that is a good idea or not for now.
Update the below code seems to not do anything:
private class NoActionsAccessibilityDelegate : View.AccessibilityDelegate
{
public override void OnInitializeAccessibilityNodeInfo(View host, Android.Views.Accessibility.AccessibilityNodeInfo info)
{
base.OnInitializeAccessibilityNodeInfo(host, info);
foreach (var action in info.ActionList.ToList()) //to list ensures we are not iterating while modifying the readonly ActionList property
{
info.RemoveAction(action);
}
}
}
If your 'view' does not have a click action but for some reason the system detects it as clickable, use the following, (I am using Xamarin for my implementation and the code to disable actions is as follows):
myView.Clickable = false;
myView.LongClickable = false;
Yes that will disable interaction with the view, but in my case the view is not meant to be interactable to begin with. For some reason the system thinks it has an action though it does not.
Im working on a simple todo list. Everything was working until fine until now. I worked on a couple methods that save data (no UI work at all) and when I came to test it all, I noticed that my list view has a blue outline around it and tapping things breaks the program. There are two scenarios:
1) run program -> tapping anywhere in list view (outside of the todo 1 cell) crashes program
2) run program -> tap todo cell -> todo info screen opens -> close info screen -> tapping anywhere in list view opens that todo info screen.
Heres an image of what that looks like
There error I get is: Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 1
static void selectedIndexListener(ListView<Todo> listView) {
listView.setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
int selectedTodoIndex = listView.getSelectionModel().getSelectedIndex();
StageController.launchSelectedTodoStage(TodoList.getTodoListInstance().getTodoAtIndex(selectedTodoIndex));
}
});
}
and then
static Todo getTodoAtIndex(int index) {
return todoList.get(index);
}
I have an ObservableList that holds all the todos and so hence the error.
Im pretty comfortable with java but I'm new to javafx. The reason i'm building this program is to practice java, not so much javafx. That being said, i have no idea where to start debugging this.
All I can say is that the last things I did was write functions to save and load data using JSON. The biggest change is the fact that the list view get populated upon running the program where as before i used to run it, then add data. However scenario number 1 (crashing) happens when I comment out the load and save methods (i.e. run the program with no initial data as I used to). At the moment I am more concerned about the first scenario than the second
I barely ever post on here so let me know if there is anything I should include to help you help me.
If nothing is selected, then
listView.getSelectionModel().getSelectedIndex()
will return -1 (see the documentation). So in the case where nothing is selected, you get an ArrayIndexOutOfBoundsException. On the other hand, if you select something, then click in an empty cell, the selection is not changed and so you get the details of the previously-selected item.
It's generally a bad idea to equate mouse clicks with selection. While they're obviously related, as you've discovered they are not the same thing.
If you want to handle mouse-clicks on a cell, instead of registering a mouse event handler with the ListView itself, use a cell factory to define a cell that has the appropriate mouse-handlers registered. So something like:
listView.setCellFactory(lv -> {
ListCell<Todo> cell = new ListCell<Todo>() {
#Override
protected void updateItem(Todo item, boolean empty) {
super.updateItem(item, empty);
setText(item == null ? "" : item.toString());
}
};
cell.setOnMouseClicked(e -> {
if (! cell.isEmpty()) {
StageController.launchSelectedTodoStage(cell.getItem());
}
});
return cell ;
});
I have Eclipse JFace wizard with five pages. In the first, I have check buttons to select which pages are to be shown - if you check all, you will pass through the whole wizard, but you can also select only specific pages, and then only that pages will be shown.
So far, I used iterator with enum objects representing each page. I called next object of iterator in getNextPage function and its if..else cases to return certain pages in proper order. The problem is, getNextPage is called not only when Next button is pressed, but also when pageComplete event firing, etc. so iterator does not update its cursor when I want, and it ends up to fast. This is snippet of my assumption:
else if(page == FirstPage )
{
// iterator contains SelectedAction - enum objects representing pages
this.pageIterator = page.getWizardPagesList().iterator();
if(pageIterator.hasNext())
{
return selectedActionToPage(pageIterator.next());
}
}
else
{
if(pageIterator.hasNext())
{
SelectedAction action = pageIterator.next();
if(!pageIterator.hasNext())
{
// we check if current page was last one
setFinished(true);
setLastPage(selectedActionToPage(action));
}
// selectedActionToPage converts enum object to WizardPage class
return selectedActionToPage(action);
}
else if((pageIterator != null) && !pageIterator.hasNext())
{
return page;
}
}
return page;
Especially, things I want to know are:
First, is there any other way to capture Next button click? I know there is NextPressed method in WizardDialog class, but I don't know how to call its instance from my Wizard class, or WizardPage.
Second, is there other way to customize navigation through pages, to go to specified pages?
No, you should not try to intercept the Next button click that logic is private to the wizard dialog and you should not be trying to interfere with it,
You can either override the WizardPage:
public IWizardPage getNextPage()
method or you can override the Wizard
public IWizardPage getNextPage(IWizardPage page)
You may also need to override the matching getPreviousPage method. You must make your code work regardless of when the method is called. You are given the information about which is the current page, your code should use that to determine the next page.
I have an Eclipse RCP with a view whose Control is a CheckboxTableViewer.
I'd like to use the WorkbenchPage's SelectionService (for reasons of loose coupling) to react to check/uncheck actions within the view in an editor.
So I do getSite().setSelectionProvider(myTableViewer); in the view's createPartControl() method.
Also, I create a listener field in the editor:
private ISelectionListener mylistener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
System.out.println(((IStructuredSelection) selection).size());
}
};
Unfortunately, I only get the number of rows that are selected printed out in the console, not the number of checked elements. I'm trying to pass myTableViewer.getCheckedElements() to the SelectionProvider somehow, but cannot find an access point :(.
You could write your own implementation of ISelectionProvider which returns the checked elements instead of using the default provider implemented by TableViewer which returns the selected elements.
I am coding a bookshop in Java and have a problem with when a new book is ordered I want the user to select whether it is a ebook or paper book. If it is an ebook I want another combo box to show on the page with called cboFormat. I have some code but it doesn't seem to work.
This is in the constructor.
if("Ebook".equals(cboBookType.getSelectedItem()))
{
cboFormat.enable();
}
else
{
cboFormat.disable();
}
Why doesn't this work? I have also previously set the format input to disabled.
This could be that you do not have a actionlistener on your combo box ? As Andrew suggested, there could be more reasons why your block does not work. If you pasted more code it would be easier to determine what the problem is. If however you are missing action listener on your combo box, code below.
public void actionPerformed(ActionEvent e) {
JComboBox cboBookType = (JComboBox)e.getSource();
String bookType= (String)cboBookType.getSelectedItem();
//and paste your ifs here
if("Ebook".equals.....){
...
}
... rest of code
}
And if you don't know what action listener is, its basically interface used by other classes to listen for an action event. i.e. user clicking button, or user selecting checkbox etc.
Dont use enable and disable try this and dont put it in the constructor because then it wont get updated you have to make a new event like itemchanged or itemstatechanged i dont know it exactly
if("Ebook".equals(cboBookType.getSelectedItem()))
{
cboFormat.setvisible(true);
}
else
{
cboFormat.setvisible(false);
}