I am a novice at using GTK widgets. I want to show a autocompletion drop-down when user types something in GTK-TextView. User should be able to select the preferred item from the drop-down Menu using keyboard or mouse. In case of GTK-TextEntry, we have built-in support for autocompletion. I want something similar for GTK TextView. Example code would be really helpful.. thanks..
Related
I am creating an application and would like to have a drop-down menu to search for files like the open menu in Gedit. What widgets do I need yo do this?
I have tried the menu widget and cannot find a way to get searching to work.
Note: I cannot find where in the Gedit source code the open menu is.
There is no widget provided by GTK out of the box to implement the gedit "Open" menu button:
Gedit implements it inside its own code base, using a GtkMenuButton that opens a GtkPopover widget containing a GtkSearchEntry, for the input field used for search, and a GtkTreeView for showing the search results. Plus, a GtkButton at the bottom to launch a GtkFileChooserDialog in order to select more files.
The tree view's model is populated using the recently used files list gathered from the default GtkRecentManager; you can get a list of all recently used files and filter them by application name; after that, you can filter them with the contents of the search entry.
If you want to know more about how a GTK application is built you should use the GTK inspector, which is provided by GTK itself as a debugging and development tool.
I open a context menu programmatically. Now additionally I would like to highlight the first menu entry.
This highlighting happens when I move with the mouse over the context menu or press the arrow keys on the keyboard. I am interested how I can trigger this programmatically.
I know the API of MenuItem does not offer this feature out of the box. So I tried to fire some MouseEvents of the type MouseOver and MouseHover, but without any success.
Has anybody an idea how to implement this feature?
I am not sure if you can change menuitem highlight colors, I haven't seen any previous example before. Look at this though: Change eclipse menuitem color
If you want to simulate what the user does and if you happen to know the location of the menu item, you can use Display#setCursorLocation() to position the mouse pointer over the menu item.
Note however, that if and how a menu item is highlighted is platform specific.
You should not use this method other than for demonstration of test purposes. If your application needs to highlight or preselect an entry in a list of choices,
you should probably use another widget. If you more describe your use case, we may be able to find a suitable widget.
I have a graphical representation for my model, and I want to implement a tooltip that look like jdt tooltip in the following :
- the tooltip shows up when hover over the object in the canvas
- being able to click on the tooltip window to focus, and scroll bar is there if needed.
- Ability to resize the tooltip window after the user change focus to it
- being able to assign command with F2 keybind to pop up the tooltip window (I know how to create command, and how to associate keybind with it)
- Ability to have hyperlinks in the tooltip text ( optional )
I do not know from where to start.
Which eclipse interfaces/classes to implement, extensions to add, adaptors to support.
I tried to find a work through tutorial but I could not.
Thanks in advance
A lot of what you describe is specific to the Eclipse Text editor and JDT code so won't be available in a Canvas so you would have to write your own code.
You can create a tooltip based on org.eclipse.jface.window.ToolTip. If the tooltip contains StyledText you can create hyperlinks.
There is an example of a fairly elaborate custom tooltip Here
What Eclipse does when the tooltip is clicked is open a new normal window of exactly the same size and contents over the tooltip and close the tooltip.
I'm trying to use GTK+ 2.0 for my GUI, but I'm not sure how I could implement a menu that slides out when a button is clicked. Making a menu disappear/re-appear instantaneously would not be difficult to do as it requires a simple change to the visibility property. This app is being developed on Windows, but I'm also planning to port it over to Linux. So any ideas on how to achieve menu transitions that work on Windows and Linux?
Maybe you can make a menu widget yourself. Last time, I made a menu widget inherited from gtk dialog. You can move the dialog anywhere you want.
Is there anyway of moving common tasks like uncommenting code (I see I can only do it for a limited selection of things like refactoring etc) onto the main GUI as a button - much like visual studio's buttons?
Commenting and uncommenting code is cmd-/.
The general answer to this question is no.
Shortcut is handy. Hit cmd-shift-? to bring down the help menu and put focus in the search field. Type something like "comment" and it'll find matching menu items.
You can customize with prebuilt actions by right/option-clicking on the toolbar and ->customize.
As for anything real custom, you have to learn the keyboard shortcuts for them.