How to create a round mouse area in QML

Stealing code from PieMenu, here’s RoundMouseArea.qml: import QtQuick 2.0 Item { id: roundMouseArea property alias mouseX: mouseArea.mouseX property alias mouseY: mouseArea.mouseY property bool containsMouse: { var x1 = width / 2; var y1 = height / 2; var x2 = mouseX; var y2 = mouseY; var distanceFromCenter = Math.pow(x1 – x2, 2) + Math.pow(y1 – … Read more

Horizontal “tab”ish scroll between views

(update 20110905: Official android tools now do this better) I cloned Eric Taix’s http://code.google.com/p/andro-views/ on github https://github.com/olibye/AndroViews Then applied the patches from above: JonO’s patch Tom de Waard’s patch Split into a library and an example, allowing simple inclusion in other projects I would have made this comment above, however I didn’t appear able to … Read more

PyQt4 center window on active screen

Modify your center method to be as follows: def center(self): frameGm = self.frameGeometry() screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos()) centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) This function is based on where the mouse point is located. It uses the screenNumber function to determine which screen the mouse is current active on. It then finds the screenGeometry of that monitor … Read more

WPF ComboBox without drop-down button

It’s possible, but you would need to retemplate it to achieve perfection. You can get most of the way there by overriding a system parameter as follows: <ComboBox xmlns:sys=”clr-namespace:System;assembly=mscorlib”> <ComboBox.Resources> <sys:Double x:Key=”{x:Static SystemParameters.VerticalScrollBarWidthKey}”>0</sys:Double> </ComboBox.Resources> <ComboBoxItem>One</ComboBoxItem> <ComboBoxItem>Two</ComboBoxItem> <ComboBoxItem>Three</ComboBoxItem> </ComboBox> However, it isn’t perfect because the focus rectangle still assumes there is a drop-down button present.

wxPython: Calling an event manually

Old topic, but I think I’ve got this figured out after being confused about it for a long time, so if anyone else comes through here looking for the answer, this might help. To manually post an event, you can use self.GetEventHandler().ProcessEvent(event) (wxWidgets docs here, wxPython docs here) or wx.PostEvent(self.GetEventHandler(), event) (wxWidgets docs, wxPython docs) … Read more

Getting rid of the gradient at the top of an Activity (Android)

This is themable; look at the windowContentOverlay attribute. In particular, you can create a new theme: <style name=”Theme.Foo” parent=”android:style/Theme.Light”> <item name=”android:windowContentOverlay”>@null</item> </style> And then declare that your activity should use this theme: <activity android:name=”.FooActivity” android:theme=”@style/Theme.Foo”> … Although a better option is to set this theme for all activities in the application, for consistency: <application android:theme=”@style/Theme.Foo”> … Read more

Multi-State Toggle Button

I implemented a multi-state toggle button, the source code is here This is how it looks: And it’s quite easy to use it: <org.honorato.multistatetogglebutton.MultiStateToggleButton android:id=”@+id/mstb_multi_id” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginTop=”10dip” mstb:values=”@array/planets_array” /> In your activity: MultiStateToggleButton button2 = (MultiStateToggleButton) this.findViewById(R.id.mstb_multi_id); button2.setOnValueChangedListener(new ToggleButton.OnValueChangedListener() { @Override public void onValueChanged(int value) { Log.d(TAG, “Value: ” + value); } });