How to write - If Visible selector? - if-statement

Not sure how to write this;
If .sub1 is visible, .homepage fadeTo .25
Sub1 has a FadeIn and I want the homepage opacity to drop to .25 if the sub1 is open?
I have this;
$("#cat").click(function(){
if ($('.sub1').is(':visible') ) {
$(".homepage").fadeTo(500, .25);}
else {
$(".homepage").fadeTo(500, 1);
}
The actual website I am making > Website Mockup > Clicking Categories fades in the sub menu and makes homepage opacity 25%, clicking categories again, makes submenu fade Out making homepage 100%.....But clicking categories > Fashion > Mens Fashion > Smart, Brings up 'Mens Smart Fashion div" but clicking categories again fades the Mens Smart fashion div out, and brings .sub1 back, but the .homepage is 100% and not 25% when the .sub1 is open

You can filter the visible .sub1 and check the length, this may not be so great if there are multiple .sub1's, maybe add a little specificity to the selector.
This technique will filter out elements with css visibility:hidden or opacity: 0 for the first .sub1 (':eq(0)'). If the length is 0 the condition will return false.
if($('.sub1:eq(0):visible').length) {
//.homepage fade to .25
}
Revised:
$("#cat").click(function(){
if ($('.sub1').css('opacity') == .25 ) {
$('.homepage').fadeTo(500, 1);
} else {
$('.homepage').fadeTo(500, .25);
}
});
I think the reason the it would not fade back in is because your condition was checking for opacicty:0 which you never reached when fading to .25. You should set the condition to check a number .25 to avoid checking multiple strings such as '.25' or '0.25'. Firefox reports '0.25'.

Related

QML Tableview horizontal scrollbar

I am using TableView QML component, where each column width is set to the table total width divided by number of columns. This introduces some fraction parts and in result, a horizontal scrollbar is almost always visible in the bottom.
But I don't want to disable scrollbar as I have ability of changing column width and because of that scrollbar may be needed. So my problem is about initial showing of this TableView component. I want to get rid of that scrollbar when component is shown first time, but don't disable it for future usage.
I am new to QML and don't know all aspects of it, but solution that came to me is to set width of each column as I do, then for the last one get sum of all previous columns and set it's width to parent.width - that sum. Can you please help me to understand how can I implement this using QML?
columnWidthProvider is calculated once at adding column. I cant reproduce your bug with this. contentWidth become same as width
TableView {
id: table
anchors.fill: parent
columnWidthProvider: function (column) {
console.log(parent.width , columns, parent.width / columns)
// wdth is 0 here
return parent.width / columns
}
ScrollBar.horizontal: ScrollBar {
policy: ScrollBar.AsNeeded
}
//....
}
But i had same issue in another view. Solution was:
Flickable {
id:view
ScrollBar.horizontal: ScrollBar {
policy: (view.width - view.contentWidth < -3) ?
ScrollBar.AlwaysOff : ScrollBar.AsNeeded}
}
}

wxPython Toolbook/Toolbar, blank space between toolbar and frame

The screenshot is a snip of the left side of my main frame. This frame has a toolbook at the top. I've set the background color of both the toolbar in the toolbook and the frame to 0,0,0 but, as you can see, there is a small blank line between the two. How do I get that line gone or how do I make it black, as well?
As a quick side question -- is there a way to change the color of the "selected" halo on the toolbar to something a bit more contrasted for black? You can see the very faint blue halo around that first icon, I'd like that to be a much lighter blue, if possible.
EDIT: Code added --
il = wx.ImageList(128, 128)
for tab in self.package.vars["tabs"]:
il.Add(wx.Image(self.package.vars["iconPath"].format(tab), wx.BITMAP_TYPE_PNG).ConvertToBitmap())
self.AssignImageList(il)
imageIdGenerator = self.getNextImageID(il.GetImageCount())
pages = [(wx.Panel(parent = self.parent, id = wx.ID_ANY), name.capitalize()) for name in self.package.vars["tabs"]]
imID = 0
toolbar = self.GetToolBar()
toolbar.SetBackgroundColour(self.package.vars["bgColor"])
toolbar.AddStretchableSpace()
for page, label in pages:
self.AddPage(page, label, imageId=imageIdGenerator.next())
page.SetBackgroundColour(c.COLORS["green"])
imID += 1
toolbar.AddStretchableSpace()
pages = [(wx.Panel(parent = self.parent, id = wx.ID_ANY), name.capitalize()) for name in self.package.vars["tabs"]]
maybe this wx.Panel in the list comprehension still has the default color. what happens if you apply SetBackgroundColour to these panels as well?
(edit)
How about removing that boarder space by
self.SetInternalBorder(0)
self here is Toolbook class. It seems to work on wxPython Demo Toolbook example.

capture 2 texts from the screen and compare them using AutoHotkey

I'm working with AutoHotkey and I need to capture two sentences from my screen and compare them. Anyone knows how to do it?
Thanks a lot!!!
OK, this shows some effort.
When you use mouseClickDrag, you have to be absolutely sure that the text will ALWAYS be at those exact locations, which is very unlikely, think about a menu bar moving the webpage down, or about using F11, doing the opposite, changing the font style/size, just zooming in/out, or making the window smaller, such that the text block becomes smaller in width but longer in length, having another banner add that is smaller or larger, et cetera. If you can use an other method (e.g. Find text and from that position, jump 10 words to the left (^{Left 10}) and then select the next 5 words (+^{Right 5}), would be much more reliable.
#NoEnv
#SingleInstance Force
#installKeybdHook
#Persistent
Return ; Stop here on startup to prevent running the whole script on startup
+Insert:: ; Using the [Shift]+[Insert] Key as the hotkey here.
MouseClickDrag,left, 540, 295, 602, 295 ; HighLight area1
Send, ^c
ClipWait, 2
MyVar1:=ClipBoard ; OR MyVar1 = %ClipBoard%
MouseClickDrag,left, 540, 295, 602, 295 ; HighLight area2
Send, ^c
ClipWait, 2
MyVar2:=ClipBoard ; OR MyVar2 = %ClipBoard%
If (MyVar1 = MyVar2)
{
MsgBox, The values %MyVar1% and %MyVar2% are equal
Send, %MyVar1%
; ClipBoard:=MyVar1 ; OR ClipBoard = %MyVar1% is alternative way (Faster)
; Send, ^v
}
Else
{
MsgBox, The values %MyVar1% and %MyVar2% are NOT equal
Send, %MyVar1% AND %MyVar2%
; ClipBoard = %MyVar1% AND %MyVar2% ; is alternative way (Faster)
; Send, ^v
}
Return
You could add some tests to only execute this when Chrome, FireFox or IE is active, but I have left that out. First chew on this code.

MSChart HowTo Create a Second CursorX to have multiple Cursor by a second Transparant ChartArea?

I am try to introduce a Second CursorX at AxisX Primary if this is possible some how?
I did try to activate a second CursorX at Secondary but that one did not work as expected,
I also readed about Line Annotation and Vertical Line Annotation and created some kind of line but a Second set of CursorX CursorY would be far nicer
I did try to create and as much as empty as possible and Transparant Second ChartArea which i try to overlay on top of the ChartArea1, i noticed InnerPlotPosition and Postion of both ChartArea should stay in track to get a full aligned Overlay, and next the CursorX of second ChartArea should be displayed on top of ChartArea1
This is what i think how it could be done but don't have a clue if it sounda for a good way to create a second CursorX maybe Line Annotation is an easier road to rome
Any help suggestion are welcome
Thanks in advance
Suppose your chart contains multiple chart areas aligned vertically, below code allows you set CursorX in each chart area:
Dim c1 As New Chart
'...here code block to build each chart area ...
'...then use below sample code to align each chart area vertically:
'c1.ChartAreas(i).AlignmentOrientation = AreaAlignmentOrientations.Vertical
'c1.ChartAreas(i).AlignWithChartArea = c1.ChartAreas(0).Name
'below set horizontal cursor (it is a gold vertical bar in each chart area):
For Each area As ChartArea In c1.ChartAreas
area.CursorX.LineColor = Color.Gold
area.CursorX.LineWidth = 3
area.CursorX.IsUserEnabled = True
area.CursorX.IsUserSelectionEnabled = True
area.CursorX.SelectionColor = System.Drawing.Color.PaleGoldenrod
Next

How can I create a 3 state custom push button?

I need to create a custom push button which will have 3 different background images corresponding to the following states:
normal
mouse over
mouse down
I would like to have a QHBoxLayout with 3 parts for left side, right side and middle side (stretching side) for the button.
Inside the middle size, I would like to have a label to show the text.
I need this button to have a "clicked" event as well.
I have been doing a lot of search to achieve this but I am really lost. I tried many things including custom widget from QWidget or styling QPushButton with stylesheets but I failed to achieve having 3 images for 3 mouse states and the clicked event.
I am looking for help.
You can use the border-image property, by composing a single image for each state like this:
| |
Left Image | Middle Image | Right Image
| |
then by specifying the left and right image sizes as the border slice sizes and in the border widths of the stylesheet. For example, if the right images were 25 pixel wide and the left ones 20, you would have:
QPushButton {
border-image: url(:/normal.png) 0 25 0 20 stretch stretch;
border-width:0 25 0 20; /* without it, only the middle images would show */
}
QPushButton:hover {
border-image: url(:/hover.png) 0 25 0 20 stretch stretch;
}
QPushButton:pressed {
border-image: url(:/pressed.png) 0 25 0 20 stretch stretch;
}
The values represent the distance between the top, right, bottom and left sides of the image.
well,first,you should have 3 picture for 3 states,and then you can use function setStyleSheet .
QPushButton *btn = new QPushButton;
btn->setStyleSheet("QPushButton{background:url(:/Resources/pause_nor.png);border:0px;}"
"QPushButton:hover{background:url(:/Resources/pause_over.png);border:0px}"
"QPushButton:pressed{background:url(:/Resources/pause_over.png); position: relative;top: 1px; left: 1px;}");