Pass the same icon through owner to all ShowDialogs - vb.net

So I have this function that all my forms use. In this function I set the current form to set a certain icon.
This goes perfectly fine.
But I have no idea how to pass this icon from the "owner" to all the ShowDialog(Me).
Is there a method I could use that just takes over the owners icon? Or does someone have another way for the next time I have to change like 50 showdialogs ?

If you inherit your dialogs from a base class, you could override the ShowDialog(parent) method to assign the parent's icon to the dialog.

Related

In React Admin, how to show SimpleFormIterator's first item by default so users do not have to click the add button the first time?

This is the component:
https://marmelab.com/react-admin/SimpleFormIterator.html
I want the first item to be required, and the user shouldn't be able to delete it.
As far as I understand, there is no built-in way for this component to do this, at this point.
I am wondering if there is a way to create a custom wrapper for this component, that can do this. Maybe render the first item separately within this custom wrapper?
To show the first item by default, you can set the default value to an empty array of objects.
<ArrayInput
source="address"
label="address"
defaultValue={[{}]}
></ArrayInput>

Refresh button in React-admin

I'm trying to access the refresh button in react-admin project. I tried using getElementsbyClassName it returns HTMLComponents Object but it isn't accessible i.e I can see the component on printing it to console but isn't accessible by code. Is there a way for me to disable this refresh button wherever I want?
I'm not sure the exact use case here, but you can create your own custom AppBar that renders essentially whatever you want: https://marmelab.com/react-admin/Theming.html#replacing-the-appbar.
also see this GitHub issue that mentions removing it entirely: https://github.com/marmelab/react-admin/issues/3383
Within your custom AppBar you could have some logic checks within your custom AppBar if you know ahead of time when you'll want it disabled (like on a certain page/component).
If you need it to be more dyanimcally disabled, you could probably have a very high-level context/state to control that as well..
**NOTE: I have built a custom AppBar before, but I haven't done any selective rendering or disabling within it. So, I can't guarantee that this is exactly correct, but it fits with other custom components I've built.

RecyclerView items have an icon that have conditional databinding for visibility but it is not refreshing

I have a recyclerview that contains a list of pre-defined UI layout elements. In the pre-defined UI layout, there is an icon that is visible if the item is a type of project. If it's not that type, it is not visible. When the user enters selection mode, I set a custom variable in the adapter to hide this icon on all items, however it is not working.
I've tried using DiffUtil callback for updating the contents (i.e. returning false for contentsIsSame when it's the one with visible icon on status change), and I see it flicker, but for only one row, and it reverts.
I've tried using notifydatasetchanged, also invalidateAll, neither works.
I looked on internet for anything that is similar to my issue, but was unable to find any solutions that worked.
In the pre-defined UI layout XML for each row:
<variable
name="isSelecting"
type="boolean"/>
Then in the visibility binding (omitted other attributes):
<ImageView
app:visibleGone="#{project.isIconVisible && !isSelecting}"/>
In RecyclerView.Adapter class code that creates the list:
listItemBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_project_list, parent, false);
When the selection button is pressed, this is called:
public void setIsSelecting(boolean isSelecting){
listItemBinding.setIsSelecting(isSelecting);
This is where I tried different methods, such as listItemBinding.invalidateAll().
If I manually set isSelecting to true or false, before the list is populated, it correctly shows/hides the icons. It's just not updating when it's changed.
After digging, I realized that listItemBinding was one individual item, not the entire list. I then found this: RecyclerView - get all existing views/viewholders
I realized that I was looking at the wrong place to set the isSelected value, and it was supposed to go into onBindViewHolder, then just call notifyDataSetChanged() and it'll handle the rest.

Change event is not being fired when changing the textField value in titanium

I have a created a project(classic) for mobile web using titanium.
I have created a textfield.
var txtField = Ti.UI.createTextField({ id:"txtId", value:"txtValue"});
I have added an event "Change".
txtField.addEventListener('change', function(e){alert("change event fired");});
after that when I am trying to change that value programmatically like
txtField.value = "Someothet text"
The change event is not triggered. Can any one please help me regarding this.
Thanks in Advance,
Swathi.
As far as I know it will only fire the "change" event when modified in the user interface. And you would also like to have a means of changing a value without firing the "change" event ;-)
You write that you have created a wrapper class. Then you should create a "setter" function (e.g. "set" or "setValue") in that wrapper class to set the value. Within the setter you will set the value AND fire the change event. This way you only have to maintain the change logic in one place.
HTH
/John
If programmatically changing the value does not fire the change event you can try to trigger it manually on the textfield:
txtField.value = "Someothet text"
txtField.fireEvent('change');
You still have to call it at all the different places but it's the same line of code.

Chrome Extension Dev: Updating javascript variables in background.html

I have a working extension, and now I'm trying to add some options/features!
I have a background page which keeps track of the "state" of each tab (per tab javascript variables that hold options/settings). Now I want to have a popup.html file which will have 1 option, a time slider. I'm not concerned with the slider or any html/css. My issue is that I'm unsure of how to communicate the new setting to the background page.
My background page contains some code like this:
chrome.browserAction.onClicked.addListener(function(tab) {
Init(tab);
});
...
function Init(tab)
{
chrome.tabs.sendRequest(tab.id,
{
'TurnOffTimer': false,
'TimerIsOn': TimerIsOn,
'Interval': Interval,
'RefreshRate': RefreshRate
}, responseCallback);
}
TimerIsOn, Interval, and RefreshRate are javascript variables on the same page.
What I need to know is how, once the slider (which is declared in the popup.html) is set and the user clicks 'ok', the timer value can be sent to background.html to be stored in the appropriate javascript variable, and the extension functionality can be updated. I can create another function called Update which will take this updated value and run, but I need to know how I can call the Update function from popup.html if it's declared in background.html.
Hopefully I'm making sense but if clarification is necessary, feel free to ask.
You can directly access background page's window object from popup with chrome.extension.getBackgroundPage(). So to change some var in bg page from popup you can just call:
chrome.extension.getBackgroundPage().Interval = 5;
You would need to change your extension a bit, as once you have popup attached to browser action button, chrome.browserAction.onClicked listener won't be firing anymore. You would need to call Init from popup manually in a similar way:
chrome.extension.getBackgroundPage().Init();
And inside Init() manually get selected tab id, as it won't be passed anymore.