I have a question to ask you.
I want to make a menu updatable using a value of a int variable (If the value of the variable changes are also modified the menu items). I know the possibility to update the string of a single menu item when its is clicked (by the creation of a function in signal connect() that update the single string of the menu item), but for the first case i don't have find nothing in internet for now!
Thank you!
Just do it.
You don't need to wrap a simple integer in all the GTK+ object and event machinery; if you know when the value changes, you can just compute a new label text for the menu item and set it (using gtk_menu_item_set_label()).
Related
I have a VB6 application that has been running for quite sometime. Currently I'm trying to update one of the form that has a combobox 2.0. Because the combobox is populated with hundreds of items - I'm trying to update it so that users are able to click on a look up button next to it, where another window opens up with all the items from the combobox. User will be able to search by keyword and/or select an item and double click on it and have it appear in the combobox. The issue I'm having is with trying to pass no value or "" when CANCEL is clicked. I'm able to pass the value if I in the properties window my STYLE Is set to COMBO rather than list. However, the issue I come across is that with COMBO the value (text) in the combobox sometimes is not aligned properly. Is there a way to pass a "" value to a combobox 2.0 without changing the style to COMBO?
If they hit cancel set the ListIndex of your combo to -1 rather than setting the text property. This is the value for no item being selected.
If you add items in a listbox you do this with list_box.insert(); Now there is a item and you can select it. For my example its a entry (textbox). But now I want to press an Button and give me the value of the entry out. I found no function in the reference for the list_box or for the list_box_row to give back any compatible object.
I tried stuff like this:
gtk_entry_get_text(GTK_ENTRY(gtk_list_box_get_selected_row(GTK_LIST_BOX(listbox)))); //listbox is a variable of typ GtkWidget and contains the listbox in
But its not working. Anyone have a solution for it? I mean it would be a bit useless to consider a listbox if you cant work with the selected stuff.
GtkListBoxRow is a GtkContainer. Specifically a (single item) GtkBin:
https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBoxRow
You should be able to call:
gtk_bin_get_child(GTK_BIN(listboxrow));
Note that a GtkListBoxRow can have only one child, though a GtkListBox can have multiple GtkListBoxRows.
I have a ComboBox implemented with an auto-completion system. My ComboBox contains more than 100 items. When users are typing text in, the auto-completion system opens the dropdown list and highlights the most relevant item. Moreover, when the dropdown list is expanded, all items are available (no filters). But the most relevant item is always at the bottom of the dropdown list.
I would like it to be in the middle, if possible. One item can have the same reference but another type than another one, that's why I need to see most of them in my dropdown by placing them in the middle.
Any idea ? It's not really important but kind of useful for them. Thanks !
Update :
Here's my ComboBox with the open dropdown. Sorry about that, I had to blur its elements. As you can see, the user starts writting the reference in the ComboBox. The autocompletion works fine, but the corresponding item is found at the end of the dropdown list (in the red frame), almost out of bounds.
I wish it would be highlighted in the middle of my dropdown list instead of so far below.
Your item search may work well, but your list isn't visually filtered, which means it's size always remains the same.
It's scrolled into view, by the wpf system, but still displaying all other items around the relevant one. The reason why it's at the bottom is because wpf Scrollviewer just finished scrolling the item into view and sees no need to scroll it further into the middle.
You could use the CollectionViewSource class. Why ?
It's simple to use, will keep your viewmodel data as it is, and you would have your relevant completion item at the top. It can be obtained by GetDefaultView(..)
Let's say you have a viewmodel flag "IsHidden", stating that it's content does not match the user input:
ICollectionView cv= CollectionViewSource.GetDefaultView(myComboBox.ItemsSource);
// switch filter on
cv.Filter = obj => (obj as myViewModel).IsHidden == false;
// switch off
cv.Filter = null
I'm using the UI-bootstrap modal window in my Angular application and I'm running into some kind of a scope problem.
I've got a modal dialog which basically has two modes. At first, it displays a list of existing items for the user to select from. In case the item the user needs is not in the list, he can click "Create", then I hide the div containing the list and display another div which contains an input form so the user can add an entry to the list. This is all really trivial stuff. The buttons to toggle which div is being shown work fine. I basically have a boolean scope variable called "create", which takes care of this.
Then, in the modal-footer I have two save buttons. One is shown when in "list" mode and the other is shown when the user is in "create" mode. Again, works fine.
Now, when the user is in "create" mode and clicks the corresponding "save" button, then I need to process the form and finally switch the state back to the list, that is set the "create" scope variable back to false, but this is not working for me. It's like I'm dealing with more than one scope since the view does not update when I update the "create" variable from the button click in the controller.
I've created a working Plunker which demonstrates this, please have a look:
http://plnkr.co/edit/KDxzH21Lmthg0bc0cfUT?p=preview
I know this is probably something really simple I'm missing. Hoping someone can point me in the right direction!
EDIT: As per the suggestion below from Mik378, I created an "intermediate" object in the scope and assigned the "create" variable to it. Now this works like I wanted to.
I updated the Plunker: http://plnkr.co/edit/KDxzH21Lmthg0bc0cfUT?p=preview
If you're using scope.myVariableToReach, you have to change that by scope.oneIntermediateObjectNotAccessibleInTheChildScope.myVariableToReach.
Otherwise, when you set scope.myVariableToReach directly, it would change the child one, not affecting the outer.
I am working on a defect in my GTK code for displaying context menus. After creating a menu with a number of menu items, I use gtk_menu_popup() to display the menu. This function takes a function pointer of type GtkMenuPositionFunc which lets me position the menu. I don't really do anything here except tell GTK to keep current position but push the menu in if part of the menu is outside the monitor (using the fourth argument to the function). My problem is that when GTK pushes the menu in, the absolute position of the menu items does not change. Hence their scroll position changes resulting in scroll bars in the menu. I want the relative position of the menu items w.r.t the menu to remain fixed. Is there any way I can do that? The GTK documentation does warn about this problem, but does not say anything about how to fix it. There is the link to it for reference:
http://library.gnome.org/devel/gtk/unstable/GtkMenu.html#GtkMenuPositionFunc
EDIT: I would have liked to include some code, but the logic is too scattered for that.
You don't need to provide a positioning function if you just want the default behavior. The default behavior is to keep the current position but make sure the menu fits on the monitor, so you can just pass NULL as the positioning function.
You can also take a look at how the default positioning function is written: http://git.gnome.org/browse/gtk+/tree/gtk/gtkmenu.c, gtk_menu_position() currently at line 4288.
PS. If your logic is too scattered to post a code sample, then you should consider cleaning it up.
I was not able to find any way to readjust the scroll-offset of menu items once the menu is pushed in. So, the workaround I used was to avoid having GTK push the menu in vertically. Hence, the original request was to create the menu at position (x,y) but resulted in length L of the menu going out of the screen, I reposition the menu at (x,y-L) in my position function. Similarly, if y<0 I change set it to (x,0). I still tell GTK to push in any menu that goes outside the screen to take care of menus going over the left and right margins.